3 namespace Drupal\Core\Menu;
5 use Drupal\Component\Plugin\Exception\PluginException;
8 * A menu link plugin for wrapping another menu link, in sensitive situations.
10 * @see \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::checkAccess()
12 class InaccessibleMenuLink extends MenuLinkBase {
15 * The wrapped menu link.
17 * @var \Drupal\Core\Menu\MenuLinkInterface
19 protected $wrappedLink;
22 * Constructs a new InaccessibleMenuLink.
24 * @param \Drupal\Core\Menu\MenuLinkInterface $wrapped_link
25 * The menu link to wrap.
27 public function __construct(MenuLinkInterface $wrapped_link) {
28 $this->wrappedLink = $wrapped_link;
29 $plugin_definition = [
30 'route_name' => '<front>',
31 'route_parameters' => [],
33 ] + $this->wrappedLink->getPluginDefinition();
34 parent::__construct([], $this->wrappedLink->getPluginId(), $plugin_definition);
40 public function getTitle() {
41 return $this->t('Inaccessible');
47 public function getDescription() {
54 public function getCacheContexts() {
55 return $this->wrappedLink->getCacheContexts();
61 public function getCacheTags() {
62 return $this->wrappedLink->getCacheTags();
68 public function getCacheMaxAge() {
69 return $this->wrappedLink->getCacheMaxAge();
76 public function updateLink(array $new_definition_values, $persist) {
77 throw new PluginException('Inaccessible menu link plugins do not support updating');