Skip to content
Snippets Groups Projects
Select Git revision
  • 07f63fe6f3ab1650ac1d82b048459fa7bb09f13f
  • 11.x default protected
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

MenuLinkAccessController.php

Blame
  • Alex Pott's avatar
    Issue #2085243 by dawehner: Rename Menu module into Menu UI module.
    Alex Pott authored
    07f63fe6
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    MenuLinkAccessController.php 1.01 KiB
    <?php
    
    /**
     * @file
     * Contains \Drupal\menu_link\MenuLinkAccessController.
     */
    
    namespace Drupal\menu_link;
    
    use Drupal\Core\Entity\EntityAccessController;
    use Drupal\Core\Entity\EntityInterface;
    use Drupal\Core\Session\AccountInterface;
    
    /**
     * Defines an access controller for the menu link entity.
     *
     * @see \Drupal\menu_link\Entity\MenuLink
     */
    class MenuLinkAccessController extends EntityAccessController {
    
      /**
       * {@inheritdoc}
       */
      protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
        $access = $account->hasPermission('administer menu');
        if ($access) {
          switch ($operation) {
            case 'reset':
              // Reset allowed for items defined via hook_menu() and customized.
              return !empty($entity->machine_name) && $entity->customized;
    
            case 'delete':
              // Only items created by the menu module can be deleted.
              return $entity->module == 'menu_ui' || $entity->updated == 1;
    
          }
        }
        return $access;
      }
    
    }