protected function ShortcutAccessController::checkAccess

Performs access checks.

This method is supposed to be overwritten by extending classes that do their own custom access checking.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check 'create' access.

string $operation: The entity operation. Usually one of 'view', 'edit', 'create' or 'delete'.

string $langcode: The language code for which to check access.

\Drupal\Core\Session\AccountInterface; $account: The user for which to check access.

Return value

bool|null TRUE if access was granted, FALSE if access was denied and NULL if access could not be determined.

Overrides EntityAccessController::checkAccess

File

drupal/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php, line 22
Contains \Drupal\shortcut\ShortcutAccessController.

Class

ShortcutAccessController
Defines the access controller for the shortcut entity type.

Namespace

Drupal\shortcut

Code

protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
  switch ($operation) {
    case 'edit':
      if (user_access('administer shortcuts', $account)) {
        return TRUE;
      }
      if (user_access('customize shortcut links', $account)) {
        return !isset($entity) || $entity == shortcut_current_displayed_set($account);
      }
      return FALSE;
      break;
    case 'delete':
      if (!user_access('administer shortcuts', $account)) {
        return FALSE;
      }
      return $entity
        ->id() != 'default';
      break;
  }
}