ShortcutAccessController.php

Contains \Drupal\shortcut\ShortcutAccessController.

Namespace

Drupal\shortcut

File

drupal/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php
View source
<?php

/**
 * @file
 * Contains \Drupal\shortcut\ShortcutAccessController.
 */
namespace Drupal\shortcut;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityAccessController;
use Drupal\Core\Session\AccountInterface;

/**
 * Defines the access controller for the shortcut entity type.
 */
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;
    }
  }

}

Classes

Namesort descending Description
ShortcutAccessController Defines the access controller for the shortcut entity type.