Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Menu/InaccessibleMenuLink.php \Drupal\Core\Menu\InaccessibleMenuLink
  2. 9 core/lib/Drupal/Core/Menu/InaccessibleMenuLink.php \Drupal\Core\Menu\InaccessibleMenuLink

A menu link plugin for wrapping another menu link, in sensitive situations.

Hierarchy

Expanded class hierarchy of InaccessibleMenuLink

See also

\Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::checkAccess()

1 file declares its use of InaccessibleMenuLink
MenuLinkTreeTest.php in core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php

File

core/lib/Drupal/Core/Menu/InaccessibleMenuLink.php, line 12

Namespace

Drupal\Core\Menu
View source
class InaccessibleMenuLink extends MenuLinkBase {

  /**
   * The wrapped menu link.
   *
   * @var \Drupal\Core\Menu\MenuLinkInterface
   */
  protected $wrappedLink;

  /**
   * Constructs a new InaccessibleMenuLink.
   *
   * @param \Drupal\Core\Menu\MenuLinkInterface $wrapped_link
   *   The menu link to wrap.
   */
  public function __construct(MenuLinkInterface $wrapped_link) {
    $this->wrappedLink = $wrapped_link;
    $plugin_definition = [
      'route_name' => '<front>',
      'route_parameters' => [],
      'url' => NULL,
    ] + $this->wrappedLink
      ->getPluginDefinition();
    parent::__construct([], $this->wrappedLink
      ->getPluginId(), $plugin_definition);
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    return $this
      ->t('Inaccessible');
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return '';
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return $this->wrappedLink
      ->getCacheContexts();
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    return $this->wrappedLink
      ->getCacheTags();
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return $this->wrappedLink
      ->getCacheMaxAge();
  }

  /**
   * {@inheritdoc}
   */
  public function updateLink(array $new_definition_values, $persist) {
    throw new PluginException('Inaccessible menu link plugins do not support updating');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InaccessibleMenuLink::$wrappedLink protected property The wrapped menu link.
InaccessibleMenuLink::getCacheContexts public function
InaccessibleMenuLink::getCacheMaxAge public function
InaccessibleMenuLink::getCacheTags public function
InaccessibleMenuLink::getDescription public function
InaccessibleMenuLink::getTitle public function
InaccessibleMenuLink::updateLink public function
InaccessibleMenuLink::__construct public function Constructs a new InaccessibleMenuLink.