Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RequestEvent.php

class RequestEvent

Allows to create a response for a request.

Call setResponse() to set the response that will be returned for the current request. The propagation of this event is stopped as soon as a response is set.

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

  • class \Symfony\Contracts\EventDispatcher\Event implements \Psr\EventDispatcher\StoppableEventInterface
    • class \Symfony\Component\HttpKernel\Event\KernelEvent extends \Symfony\Contracts\EventDispatcher\Event
      • class \Symfony\Component\HttpKernel\Event\RequestEvent extends \Symfony\Component\HttpKernel\Event\KernelEvent

Expanded class hierarchy of RequestEvent

21 files declare their use of RequestEvent
AbstractSessionListener.php in vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php
AddRequestFormatsListener.php in vendor/symfony/http-kernel/EventListener/AddRequestFormatsListener.php
AjaxResponseSubscriber.php in core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php
AuthenticationSubscriber.php in core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
DynamicPageCacheSubscriber.php in core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php

... See full list

File

vendor/symfony/http-kernel/Event/RequestEvent.php, line 25

Namespace

Symfony\Component\HttpKernel\Event
View source
class RequestEvent extends KernelEvent {
    private ?Response $response = null;
    
    /**
     * Returns the response object.
     */
    public function getResponse() : ?Response {
        return $this->response;
    }
    
    /**
     * Sets a response and stops event propagation.
     */
    public function setResponse(Response $response) : void {
        $this->response = $response;
        $this->stopPropagation();
    }
    
    /**
     * Returns whether a response was set.
     *
     * @psalm-assert-if-true !null $this->getResponse()
     */
    public function hasResponse() : bool {
        return null !== $this->response;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
Event::$propagationStopped private property
Event::isPropagationStopped public function Is propagation stopped? Overrides StoppableEventInterface::isPropagationStopped
Event::stopPropagation public function Stops the propagation of the event to further event listeners. 1
KernelEvent::getKernel public function Returns the kernel in which this event was thrown.
KernelEvent::getRequest public function Returns the request the kernel is currently processing.
KernelEvent::getRequestType public function Returns the request type the kernel is currently processing.
KernelEvent::isMainRequest public function Checks if this is the main request.
KernelEvent::__construct public function 6
RequestEvent::$response private property
RequestEvent::getResponse public function Returns the response object.
RequestEvent::hasResponse public function Returns whether a response was set.
RequestEvent::setResponse public function Sets a response and stops event propagation.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal