Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function applies($definition, $name, Route $route)
 {
     if (parent::applies($definition, $name, $route)) {
         return !empty($definition['tempstore']) && $definition['type'] === 'entity:view';
     }
     return FALSE;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function applies($definition, $name, Route $route)
 {
     if (parent::applies($definition, $name, $route)) {
         return $definition['type'] === 'entity:foo_bar';
     }
     return FALSE;
 }
 /**
  * {@inheritdoc}
  */
 public function applies($definition, $name, Route $route)
 {
     if (parent::applies($definition, $name, $route)) {
         // As we only want to override EntityConverter for ConfigEntities, find
         // out whether the current entity is a ConfigEntity.
         $entity_type_id = substr($definition['type'], strlen('entity:'));
         $entity_type = $this->entityManager->getDefinition($entity_type_id);
         if ($entity_type->isSubclassOf('\\Drupal\\Core\\Config\\Entity\\ConfigEntityInterface')) {
             return $this->adminContext->isAdminRoute($route);
         }
     }
     return FALSE;
 }
 /**
  * {@inheritdoc}
  */
 public function applies($definition, $name, Route $route)
 {
     if (parent::applies($definition, $name, $route)) {
         $entity_type_id = substr($definition['type'], strlen('entity:'));
         // If the entity type is dynamic, defer checking to self::convert().
         if (strpos($entity_type_id, '{') === 0) {
             return TRUE;
         }
         // As we only want to override EntityConverter for ConfigEntities, find
         // out whether the current entity is a ConfigEntity.
         $entity_type = $this->entityManager->getDefinition($entity_type_id);
         if ($entity_type->isSubclassOf('\\Drupal\\Core\\Config\\Entity\\ConfigEntityInterface')) {
             return $this->adminContext->isAdminRoute($route);
         }
     }
     return FALSE;
 }
Ejemplo n.º 5
0
 /**
  * Tests the convert() method with an invalid dynamic entity type.
  *
  * @expectedException \Drupal\Core\ParamConverter\ParamNotConvertedException
  * @expectedExceptionMessage The "foo" parameter was not converted because the "invalid_id" parameter is missing
  */
 public function testConvertWithInvalidDynamicEntityType()
 {
     $this->entityConverter->convert('id', ['type' => 'entity:{invalid_id}'], 'foo', ['foo' => 'id']);
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function convert($value, $definition, $name, array $defaults)
 {
     $entity = parent::convert($value, $definition, $name, $defaults);
     if ($entity && $this->moderationInformation->isModeratedEntity($entity) && !$this->moderationInformation->isLatestRevision($entity)) {
         $entity_type_id = $this->getEntityTypeFromDefaults($definition, $name, $defaults);
         $latest_revision = $this->moderationInformation->getLatestRevision($entity_type_id, $value);
         // If the entity type is translatable, ensure we return the proper
         // translation object for the current context.
         if ($latest_revision instanceof EntityInterface && $entity instanceof TranslatableInterface) {
             $latest_revision = $this->entityManager->getTranslationFromContext($latest_revision, NULL, array('operation' => 'entity_upcast'));
         }
         if ($latest_revision->isRevisionTranslationAffected()) {
             $entity = $latest_revision;
         }
     }
     return $entity;
 }