You are here

public function ReorderChildrenAccess::access in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 src/Routing/ReorderChildrenAccess.php \Drupal\entity_hierarchy\Routing\ReorderChildrenAccess::access()

Checks access.

Parameters

\Symfony\Component\Routing\Route $route: Route being access checked.

\Symfony\Component\HttpFoundation\Request $request: The request object.

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

File

src/Routing/ReorderChildrenAccess.php, line 65

Class

ReorderChildrenAccess
Defines a class for limiting the children form to entities with hierarchies.

Namespace

Drupal\entity_hierarchy\Routing

Code

public function access(Route $route, Request $request = NULL, AccountInterface $account = NULL) {
  $entity_type = $route
    ->getOption(EntityHierarchyRouteProvider::ENTITY_HIERARCHY_ENTITY_TYPE);
  $entity = $this->routeMatch
    ->getParameter($entity_type);
  if ($entity && $this->parentCandidate
    ->getCandidateFields($entity)) {
    return AccessResult::allowed()
      ->setCacheMaxAge(0);
  }
  return AccessResult::forbidden();
}