class Menu

Same name in this branch
  1. main core/modules/system/src/Plugin/migrate/source/Menu.php \Drupal\system\Plugin\migrate\source\Menu
Same name and namespace in other branches
  1. 11.x core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu
  2. 11.x core/modules/system/src/Plugin/migrate/source/Menu.php \Drupal\system\Plugin\migrate\source\Menu
  3. 10 core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu
  4. 10 core/modules/system/src/Plugin/migrate/source/Menu.php \Drupal\system\Plugin\migrate\source\Menu
  5. 9 core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu
  6. 9 core/modules/system/src/Plugin/migrate/source/Menu.php \Drupal\system\Plugin\migrate\source\Menu
  7. 8.9.x core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu
  8. 8.9.x core/modules/system/src/Plugin/migrate/source/Menu.php \Drupal\system\Plugin\migrate\source\Menu

Defines the Menu configuration entity class.

Attributes

#[ConfigEntityType(id: 'menu', label: new TranslatableMarkup('Menu'), label_collection: new TranslatableMarkup('Menus'), label_singular: new TranslatableMarkup('menu'), label_plural: new TranslatableMarkup('menus'), entity_keys: [ 'id' => 'id', 'label' => 'label', ], handlers: [ 'access' => MenuAccessControlHandler::class, 'storage' => MenuStorage::class, ], admin_permission: 'administer menu', label_count: [ 'singular' => '@count menu', 'plural' => '@count menus', ], config_export: [ 'id', 'label', 'description', 'locked', ])]

Hierarchy

Expanded class hierarchy of Menu

23 files declare their use of Menu
BlockHooks.php in core/modules/block/src/Hook/BlockHooks.php
BlockXssTest.php in core/modules/block/tests/src/Functional/BlockXssTest.php
MenuAccessControlHandlerTest.php in core/modules/system/tests/src/Kernel/MenuAccessControlHandlerTest.php
MenuBlockTest.php in core/modules/menu_ui/tests/src/Kernel/MenuBlockTest.php
MenuCacheTagsTest.php in core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php

... See full list

74 string references to 'Menu'
BlockPluginId::transform in core/modules/block/src/Plugin/migrate/process/BlockPluginId.php
Set the block plugin id.
ConfigEntityMapper::getContextualLinkGroup in core/modules/config_translation/src/ConfigEntityMapper.php
Returns the name of the contextual link group to add contextual links to.
ConfigExistsConstraintValidatorTest::testValidation in core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php
Tests the ConfigExists constraint validator.
core.services.yml in core/core.services.yml
core/core.services.yml
d6_menu.yml in core/modules/system/migrations/d6_menu.yml
core/modules/system/migrations/d6_menu.yml

... See full list

File

core/modules/system/src/Entity/Menu.php, line 16

Namespace

Drupal\system\Entity
View source
class Menu extends ConfigEntityBase implements MenuInterface {
  
  /**
   * The menu machine name.
   *
   * @var string
   */
  protected $id;
  
  /**
   * The human-readable name of the menu entity.
   *
   * @var string
   */
  protected $label;
  
  /**
   * The menu description.
   *
   * @var string
   */
  protected $description;
  
  /**
   * The locked status of this menu.
   *
   * @var bool
   */
  protected $locked = FALSE;
  
  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this->description;
  }
  
  /**
   * {@inheritdoc}
   */
  public function isLocked() {
    return (bool) $this->locked;
  }
  
  /**
   * {@inheritdoc}
   */
  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    parent::preDelete($storage, $entities);
    /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
    $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
    foreach ($entities as $menu) {
      // Delete all links from the menu.
      $menu_link_manager->deleteLinksInMenu($menu->id());
    }
  }
  
  /**
   * {@inheritdoc}
   */
  public function save() {
    $return = parent::save();
    \Drupal::cache('menu')->deleteAll();
    // Invalidate the block cache to update menu-based derivatives.
    if (\Drupal::moduleHandler()->moduleExists('block')) {
      \Drupal::service('plugin.manager.block')->clearCachedDefinitions();
    }
    return $return;
  }
  
  /**
   * {@inheritdoc}
   */
  public function delete() {
    parent::delete();
    \Drupal::cache('menu')->deleteAll();
    // Invalidate the block cache to update menu-based derivatives.
    if (\Drupal::moduleHandler()->moduleExists('block')) {
      \Drupal::service('plugin.manager.block')->clearCachedDefinitions();
    }
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.