class RedirectEventSubscriber
Changes the response to a redirect, if a redirect rules action was executed .
Hierarchy
- class \Drupal\rules\EventSubscriber\RedirectEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of RedirectEventSubscriber
1 string reference to 'RedirectEventSubscriber'
1 service uses RedirectEventSubscriber
File
-
src/
EventSubscriber/ RedirectEventSubscriber.php, line 13
Namespace
Drupal\rules\EventSubscriberView source
class RedirectEventSubscriber implements EventSubscriberInterface {
/**
* Checks if a redirect rules action was executed.
*
* Redirects to the provided url if there is one.
*
* @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
* The response event.
*/
public function checkRedirectIssued(ResponseEvent $event) {
$request = $event->getRequest();
$redirect_url = $request->attributes
->get('_rules_redirect_action_url');
if (isset($redirect_url)) {
$event->setResponse(new RedirectResponse($redirect_url));
}
}
/**
* Registers the methods in this class that should be listeners.
*
* @return array
* An array of event listener definitions.
*/
public static function getSubscribedEvents() {
$events[KernelEvents::RESPONSE][] = [
'checkRedirectIssued',
];
return $events;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
RedirectEventSubscriber::checkRedirectIssued | public | function | Checks if a redirect rules action was executed. |
RedirectEventSubscriber::getSubscribedEvents | public static | function | Registers the methods in this class that should be listeners. |