You are here

public function ListUsageController::checkAccess in Entity Usage 8

Same name and namespace in other branches
  1. 8.4 src/Controller/ListUsageController.php \Drupal\entity_usage\Controller\ListUsageController::checkAccess()
  2. 8.2 src/Controller/ListUsageController.php \Drupal\entity_usage\Controller\ListUsageController::checkAccess()
  3. 8.3 src/Controller/ListUsageController.php \Drupal\entity_usage\Controller\ListUsageController::checkAccess()

Checks access based on whether the user can view the current entity.

Parameters

string $type: The entity type.

int $id: The entity ID.

Return value

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

1 call to ListUsageController::checkAccess()
LocalTaskUsageController::checkAccessLocalTask in src/Controller/LocalTaskUsageController.php
Checks access based on whether the user can view the current entity.
1 string reference to 'ListUsageController::checkAccess'
entity_usage.routing.yml in ./entity_usage.routing.yml
entity_usage.routing.yml

File

src/Controller/ListUsageController.php, line 192

Class

ListUsageController
Controller for our pages.

Namespace

Drupal\entity_usage\Controller

Code

public function checkAccess($type, $id) {
  $entity = $this->entityTypeManager
    ->getStorage($type)
    ->load($id);
  if (!$entity || !$entity
    ->access('view')) {
    return AccessResult::forbidden();
  }
  return AccessResult::allowed();
}