EntityTypeParamConverter.php in Synonyms 8
File
src/ParamConverter/EntityTypeParamConverter.php
View source
<?php
namespace Drupal\synonyms\ParamConverter;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Symfony\Component\Routing\Route;
class EntityTypeParamConverter implements ParamConverterInterface {
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
public function convert($value, $definition, $name, array $defaults) {
return $this->entityTypeManager
->getDefinition($value);
}
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'synonyms_entity_type';
}
}