class ShortcutAccessController

Defines the access controller for the shortcut entity type.

Hierarchy

Expanded class hierarchy of ShortcutAccessController

File

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

Namespace

Drupal\shortcut
View source
class ShortcutAccessController extends EntityAccessController {

  /**
   * {@inheritdoc}
   */
  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;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityAccessController::$accessCache protected property Stores calculcated access check results.
EntityAccessController::access public function Checks access to an operation on a given entity or entity translation. Overrides EntityAccessControllerInterface::access 1
EntityAccessController::getCache protected function Tries to retrieve a previously cached access value from the static cache.
EntityAccessController::resetCache public function Clears all cached access checks. Overrides EntityAccessControllerInterface::resetCache
EntityAccessController::setCache protected function Statically caches whether the given user has access.
ShortcutAccessController::checkAccess protected function Performs access checks. Overrides EntityAccessController::checkAccess