You are here

class EntityTypeParamConverter in Synonyms 8

Same name and namespace in other branches
  1. 2.0.x src/ParamConverter/EntityTypeParamConverter.php \Drupal\synonyms\ParamConverter\EntityTypeParamConverter

Param converter service for entity types.

Hierarchy

Expanded class hierarchy of EntityTypeParamConverter

1 string reference to 'EntityTypeParamConverter'
synonyms.services.yml in ./synonyms.services.yml
synonyms.services.yml
1 service uses EntityTypeParamConverter
synonyms.param_converter.entity_type in ./synonyms.services.yml
Drupal\synonyms\ParamConverter\EntityTypeParamConverter

File

src/ParamConverter/EntityTypeParamConverter.php, line 12

Namespace

Drupal\synonyms\ParamConverter
View source
class EntityTypeParamConverter implements ParamConverterInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * EntityTypeParamConverter constructor.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function convert($value, $definition, $name, array $defaults) {
    return $this->entityTypeManager
      ->getDefinition($value);
  }

  /**
   * {@inheritdoc}
   */
  public function applies($definition, $name, Route $route) {
    return !empty($definition['type']) && $definition['type'] == 'synonyms_entity_type';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityTypeParamConverter::$entityTypeManager protected property The entity type manager.
EntityTypeParamConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
EntityTypeParamConverter::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert
EntityTypeParamConverter::__construct public function EntityTypeParamConverter constructor.