Issue #2028585 followup by tim.plunkett: Replace entity_page_create_access() by an access controller.

8.0.x
Alex Pott 2013-06-29 12:36:37 +01:00
parent 54e9f29c5e
commit 0453593c66
1 changed files with 9 additions and 2 deletions

View File

@ -23,6 +23,13 @@ class EntityCreateAccessCheck implements AccessCheckInterface {
*/
protected $entityManager;
/**
* The key used by the routing requirement.
*
* @var string
*/
protected $requirementsKey = '_entity_create_access';
/**
* Constructs a EntityCreateAccessCheck object.
*
@ -37,14 +44,14 @@ class EntityCreateAccessCheck implements AccessCheckInterface {
* {@inheritdoc}
*/
public function applies(Route $route) {
return array_key_exists('_entity_create_access', $route->getRequirements());
return array_key_exists($this->requirementsKey, $route->getRequirements());
}
/**
* {@inheritdoc}
*/
public function access(Route $route, Request $request) {
list($entity_type, $bundle) = explode(':', $route->getRequirement('_entity_create_access') . ':');
list($entity_type, $bundle) = explode(':', $route->getRequirement($this->requirementsKey) . ':');
$definition = $this->entityManager->getDefinition($entity_type);