class LanguageBlock
Same name in this branch
- 10 core/modules/language/src/Plugin/Block/LanguageBlock.php \Drupal\language\Plugin\Block\LanguageBlock
Same name in other branches
- 9 core/modules/language/src/Plugin/Derivative/LanguageBlock.php \Drupal\language\Plugin\Derivative\LanguageBlock
- 9 core/modules/language/src/Plugin/Block/LanguageBlock.php \Drupal\language\Plugin\Block\LanguageBlock
- 8.9.x core/modules/language/src/Plugin/Derivative/LanguageBlock.php \Drupal\language\Plugin\Derivative\LanguageBlock
- 8.9.x core/modules/language/src/Plugin/Block/LanguageBlock.php \Drupal\language\Plugin\Block\LanguageBlock
- 11.x core/modules/language/src/Plugin/Derivative/LanguageBlock.php \Drupal\language\Plugin\Derivative\LanguageBlock
- 11.x core/modules/language/src/Plugin/Block/LanguageBlock.php \Drupal\language\Plugin\Block\LanguageBlock
Provides language switcher block plugin definitions for all languages.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements \Drupal\Component\Plugin\Derivative\DeriverInterface
- class \Drupal\language\Plugin\Derivative\LanguageBlock extends \Drupal\Component\Plugin\Derivative\DeriverBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of LanguageBlock
1 file declares its use of LanguageBlock
- LanguageBlock.php in core/
modules/ language/ src/ Plugin/ Block/ LanguageBlock.php
File
-
core/
modules/ language/ src/ Plugin/ Derivative/ LanguageBlock.php, line 12
Namespace
Drupal\language\Plugin\DerivativeView source
class LanguageBlock extends DeriverBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$language_manager = \Drupal::languageManager();
if ($language_manager instanceof ConfigurableLanguageManagerInterface) {
$info = $language_manager->getDefinedLanguageTypesInfo();
$configurable_types = $language_manager->getLanguageTypes();
foreach ($configurable_types as $type) {
$this->derivatives[$type] = $base_plugin_definition;
$this->derivatives[$type]['admin_label'] = $this->t('Language switcher (@type)', [
'@type' => $info[$type]['name'],
]);
}
// If there is just one configurable type then change the title of the
// block.
if (count($configurable_types) == 1) {
$this->derivatives[reset($configurable_types)]['admin_label'] = $this->t('Language switcher');
}
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
DeriverBase::$derivatives | protected | property | List of derivative definitions. | 1 | |
DeriverBase::getDerivativeDefinition | public | function | Gets the definition of a derivative plugin. | Overrides DeriverInterface::getDerivativeDefinition | |
LanguageBlock::getDerivativeDefinitions | public | function | Gets the definition of all derivatives of a base plugin. | Overrides DeriverBase::getDerivativeDefinitions | |
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | |
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | ||
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | ||
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | ||
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | |
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.