diff --git a/masquerade.links.menu.yml b/masquerade.links.menu.yml index 65a48d0..22190e6 100644 --- a/masquerade.links.menu.yml +++ b/masquerade.links.menu.yml @@ -4,3 +4,4 @@ masquerade.unmasquerade: description: 'Switch back to your user account.' route_name: masquerade.unmasquerade weight: -50 + class: \Drupal\masquerade\Plugin\Menu\UnmasqueradeMenuLink diff --git a/src/Plugin/Menu/UnmasqueradeMenuLink.php b/src/Plugin/Menu/UnmasqueradeMenuLink.php new file mode 100644 index 0000000..61f0439 --- /dev/null +++ b/src/Plugin/Menu/UnmasqueradeMenuLink.php @@ -0,0 +1,62 @@ +masquerade = $masquerade; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('menu_link.static.overrides'), + $container->get('masquerade') + ); + } + + /** + * {@inheritdoc} + */ + public function isEnabled() { + return $this->masquerade->isMasquerading(); + } + +}