ProfileLocalAction.php in Profile 8
File
src/Plugin/Menu/LocalAction/ProfileLocalAction.php
View source
<?php
namespace Drupal\profile\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 ProfileLocalAction 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;
}
}