LanguageConverter.php
Same filename in this branch
Same filename in other branches
- 9 core/modules/language/src/ProxyClass/LanguageConverter.php
- 9 core/modules/language/src/LanguageConverter.php
- 8.9.x core/modules/language/src/ProxyClass/LanguageConverter.php
- 8.9.x core/modules/language/src/LanguageConverter.php
- 11.x core/modules/language/src/ProxyClass/LanguageConverter.php
- 11.x core/modules/language/src/LanguageConverter.php
Namespace
Drupal\languageFile
-
core/
modules/ language/ src/ LanguageConverter.php
View source
<?php
namespace Drupal\language;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Symfony\Component\Routing\Route;
/**
* Converts parameters for upcasting entity IDs to full objects.
*/
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';
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
LanguageConverter | Converts parameters for upcasting entity IDs to full objects. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.