MenuLinkAccessController.php 793 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
<?php

/**
 * @file
 * Contains \Drupal\menu_link\MenuLinkAccessController.
 */

namespace Drupal\menu_link;

use Drupal\Core\Entity\EntityAccessController;
use Drupal\Core\Entity\EntityInterface;
12
use Drupal\user\Plugin\Core\Entity\User;
13
14
15
16
17
18
19
20
21
22
23

/**
 * Defines an access controller for the menu link entity.
 *
 * @see \Drupal\menu_link\Plugin\Core\Entity\MenuLink
 */
class MenuLinkAccessController extends EntityAccessController {

  /**
   * {@inheritdoc}
   */
24
  protected function checkAccess(EntityInterface $entity, $operation, $langcode, User $account) {
25
26
27
28
29
30
31
32
33
    $access = user_access('administer menu', $account);
    if ($access && $operation == 'delete') {
      // Only items created by the menu module can be deleted.
      return $entity->module == 'menu';
    }
    return $access;
  }

}