fixity = $fixity; } /** * {@inheritdoc} */ public function convert($value, $definition, $name, array $defaults) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = parent::convert($value, $definition, $name, $defaults); return $this->fixity->fromEntity($entity); } /** * {@inheritdoc} */ public function applies($definition, $name, Route $route) { $supported_entity_types = $this->fixity->fromEntityTypes(); if (!empty($definition['type']) && strpos($definition['type'], 'fixity:') === 0) { $entity_type_id = substr($definition['type'], strlen('fixity:')); if (strpos($definition['type'], '{') !== FALSE) { $entity_type_slug = substr($entity_type_id, 1, -1); if ($name != $entity_type_slug && in_array($entity_type_slug, $route->compile()->getVariables(), TRUE)) { return in_array($entity_type_slug, $supported_entity_types); } } return in_array($entity_type_id, $supported_entity_types); } return FALSE; } }