/** * Tests the applies() method. * * @dataProvider providerTestApplies * * @covers ::applies */ public function testApplies(array $definition, $name, Route $route, $applies) { $this->entityManager->expects($this->any())->method('hasDefinition')->willReturnCallback(function ($entity_type) { return 'entity_test' == $entity_type; }); $this->assertEquals($applies, $this->entityConverter->applies($definition, $name, $route)); }
/** * {@inheritdoc} */ public function applies($definition, $name, Route $route) { if (parent::applies($definition, $name, $route)) { return !empty($definition['tempstore']) && $definition['type'] === 'entity:view'; } return FALSE; }
/** * {@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; }