class LanguageConverter in Zircon Profile 8
Same name in this branch
- 8 core/modules/language/src/LanguageConverter.php \Drupal\language\LanguageConverter
- 8 core/modules/language/src/ProxyClass/LanguageConverter.php \Drupal\language\ProxyClass\LanguageConverter
Same name and namespace in other branches
- 8.0 core/modules/language/src/LanguageConverter.php \Drupal\language\LanguageConverter
Converts parameters for upcasting entity IDs to full objects.
Hierarchy
- class \Drupal\language\LanguageConverter implements 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 17 - Contains \Drupal\language\LanguageConverter.
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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LanguageConverter:: |
protected | property | The language manager. | |
LanguageConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
LanguageConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
LanguageConverter:: |
public | function | Constructs a new LanguageConverter. |