LanguageConverter.php in Drupal 8
File
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;
class LanguageConverter implements ParamConverterInterface {
protected $languageManager;
public function __construct(LanguageManagerInterface $language_manager) {
$this->languageManager = $language_manager;
}
public function convert($value, $definition, $name, array $defaults) {
if (!empty($value)) {
return $this->languageManager
->getLanguage($value);
}
return NULL;
}
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'language';
}
}