39090e23d9fbb38b41438ed469fe3a8d0eddde65
[yaffs-website] / web / core / lib / Drupal / Core / Menu / InaccessibleMenuLink.php
1 <?php
2
3 namespace Drupal\Core\Menu;
4
5 use Drupal\Component\Plugin\Exception\PluginException;
6
7 /**
8  * A menu link plugin for wrapping another menu link, in sensitive situations.
9  *
10  * @see \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::checkAccess()
11  */
12 class InaccessibleMenuLink extends MenuLinkBase {
13
14   /**
15    * The wrapped menu link.
16    *
17    * @var \Drupal\Core\Menu\MenuLinkInterface
18    */
19   protected $wrappedLink;
20
21   /**
22    * Constructs a new InaccessibleMenuLink.
23    *
24    * @param \Drupal\Core\Menu\MenuLinkInterface $wrapped_link
25    *   The menu link to wrap.
26    */
27   public function __construct(MenuLinkInterface $wrapped_link) {
28     $this->wrappedLink = $wrapped_link;
29     $plugin_definition = [
30       'route_name' => '<front>',
31       'route_parameters' => [],
32       'url' => NULL,
33     ] + $this->wrappedLink->getPluginDefinition();
34     parent::__construct([], $this->wrappedLink->getPluginId(), $plugin_definition);
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function getTitle() {
41     return $this->t('Inaccessible');
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function getDescription() {
48     return '';
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public function getCacheContexts() {
55     return $this->wrappedLink->getCacheContexts();
56   }
57
58   /**
59    * {@inheritdoc}
60    */
61   public function getCacheTags() {
62     return $this->wrappedLink->getCacheTags();
63   }
64
65   /**
66    * {@inheritdoc}
67    */
68   public function getCacheMaxAge() {
69     return $this->wrappedLink->getCacheMaxAge();
70   }
71
72
73   /**
74    * {@inheritdoc}
75    */
76   public function updateLink(array $new_definition_values, $persist) {
77     throw new PluginException('Inaccessible menu link plugins do not support updating');
78   }
79
80 }