You are here

public function LatestRevisionCheck::access in Workbench Moderation 8

Same name and namespace in other branches
  1. 8.2 src/Access/LatestRevisionCheck.php \Drupal\workbench_moderation\Access\LatestRevisionCheck::access()

Checks that there is a forward revision available.

This checker assumes the presence of an '_entity_access' requirement key in the same form as used by EntityAccessCheck.

Parameters

\Symfony\Component\Routing\Route $route: The route to check against.

\Drupal\Core\Routing\RouteMatchInterface $route_match: The parametrized route.

Return value

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

See also

EntityAccessCheck

File

src/Access/LatestRevisionCheck.php, line 50

Class

LatestRevisionCheck
Define class for revision checks.

Namespace

Drupal\workbench_moderation\Access

Code

public function access(Route $route, RouteMatchInterface $route_match) {

  // This tab should not show up period unless there's a reason to show it.
  // @todo Do we need any extra cache tags here?
  $entity = $this
    ->loadEntity($route, $route_match);
  return $this->moderationInfo
    ->hasForwardRevision($entity) ? AccessResult::allowed()
    ->addCacheableDependency($entity) : AccessResult::forbidden()
    ->addCacheableDependency($entity);
}