public function GotoAction::execute in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/action/src/Plugin/Action/GotoAction.php \Drupal\action\Plugin\Action\GotoAction::execute()
Executes the plugin.
Overrides ExecutableInterface::execute
File
- core/
modules/ action/ src/ Plugin/ Action/ GotoAction.php, line 78 - Contains \Drupal\action\Plugin\Action\GotoAction.
Class
- GotoAction
- Redirects to a different URL.
Namespace
Drupal\action\Plugin\ActionCode
public function execute($object = NULL) {
$url = $this->configuration['url'];
// Leave external URLs unchanged, and assemble others as absolute URLs
// relative to the site's base URL.
if (!UrlHelper::isExternal($url)) {
$parts = UrlHelper::parse($url);
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
if ($parts['path'] === '<front>') {
$parts['path'] = '';
}
$uri = 'base:' . $parts['path'];
$options = [
'query' => $parts['query'],
'fragment' => $parts['fragment'],
'absolute' => TRUE,
];
// Treat this as if it's user input of a path relative to the site's
// base URL.
$url = $this->unroutedUrlAssembler
->assemble($uri, $options);
}
$response = new RedirectResponse($url);
$listener = function ($event) use ($response) {
$event
->setResponse($response);
};
// Add the listener to the event dispatcher.
$this->dispatcher
->addListener(KernelEvents::RESPONSE, $listener);
}