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