LanguageConverter.php in Zircon Profile 8.0
Same filename in this branch
Same filename and directory in other branches
Contains \Drupal\language\LanguageConverter.
Namespace
Drupal\languageFile
core/modules/language/src/LanguageConverter.phpView source
<?php
/**
* @file
* Contains \Drupal\language\LanguageConverter.
*/
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
Name | Description |
---|---|
LanguageConverter | Converts parameters for upcasting entity IDs to full objects. |