class LanguageConverter
Same name in this branch
- 11.x core/modules/language/src/ProxyClass/LanguageConverter.php \Drupal\language\ProxyClass\LanguageConverter
Same name in other branches
- 9 core/modules/language/src/ProxyClass/LanguageConverter.php \Drupal\language\ProxyClass\LanguageConverter
- 9 core/modules/language/src/LanguageConverter.php \Drupal\language\LanguageConverter
- 8.9.x core/modules/language/src/ProxyClass/LanguageConverter.php \Drupal\language\ProxyClass\LanguageConverter
- 8.9.x core/modules/language/src/LanguageConverter.php \Drupal\language\LanguageConverter
- 10 core/modules/language/src/ProxyClass/LanguageConverter.php \Drupal\language\ProxyClass\LanguageConverter
- 10 core/modules/language/src/LanguageConverter.php \Drupal\language\LanguageConverter
Converts parameters for upcasting entity IDs to full objects.
Hierarchy
- class \Drupal\language\LanguageConverter implements \Drupal\Core\ParamConverter\ParamConverterInterface
Expanded class hierarchy of LanguageConverter
1 string reference to 'LanguageConverter'
- language.services.yml in core/
modules/ language/ language.services.yml - core/modules/language/language.services.yml
1 service uses LanguageConverter
- language_converter in core/
modules/ language/ language.services.yml - Drupal\language\LanguageConverter
File
-
core/
modules/ language/ src/ LanguageConverter.php, line 12
Namespace
Drupal\languageView source
class LanguageConverter implements ParamConverterInterface {
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* Constructs a new LanguageConverter.
*
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
*/
public function __construct(LanguageManagerInterface $language_manager) {
$this->languageManager = $language_manager;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
if (!empty($value)) {
return $this->languageManager
->getLanguage($value);
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'language';
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
LanguageConverter::$languageManager | protected | property | The language manager. | |
LanguageConverter::applies | public | function | Determines if the converter applies to a specific route and variable. | Overrides ParamConverterInterface::applies |
LanguageConverter::convert | public | function | Converts path variables to their corresponding objects. | Overrides ParamConverterInterface::convert |
LanguageConverter::__construct | public | function | Constructs a new LanguageConverter. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.