class BootstrapLanguagesBlock in Bootstrap Languages 8
Same name in this branch
- 8 src/Plugin/Derivative/BootstrapLanguagesBlock.php \Drupal\bootstrap_languages\Plugin\Derivative\BootstrapLanguagesBlock
- 8 src/Plugin/Block/BootstrapLanguagesBlock.php \Drupal\bootstrap_languages\Plugin\Block\BootstrapLanguagesBlock
Provides language switcher block plugin definitions for all languages.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\bootstrap_languages\Plugin\Derivative\BootstrapLanguagesBlock uses StringTranslationTrait
Expanded class hierarchy of BootstrapLanguagesBlock
File
- src/
Plugin/ Derivative/ BootstrapLanguagesBlock.php, line 12
Namespace
Drupal\bootstrap_languages\Plugin\DerivativeView source
class BootstrapLanguagesBlock 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('Bootstrap 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('Bootstrap Language switcher');
}
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BootstrapLanguagesBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |