MenuLinkAdd.php in Zircon Profile 8
File
core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php
View source
<?php
namespace Drupal\menu_ui\Plugin\Menu\LocalAction;
use Drupal\Core\Menu\LocalActionDefault;
use Drupal\Core\Routing\RedirectDestinationInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Routing\RouteProviderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MenuLinkAdd extends LocalActionDefault {
private $redirectDestination;
public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider, RedirectDestinationInterface $redirect_destination) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $route_provider);
$this->redirectDestination = $redirect_destination;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('router.route_provider'), $container
->get('redirect.destination'));
}
public function getOptions(RouteMatchInterface $route_match) {
$options = parent::getOptions($route_match);
$options['query']['destination'] = $this->redirectDestination
->get();
return $options;
}
}
Classes
Name |
Description |
MenuLinkAdd |
Modifies the 'Add link' local action to add a destination. |