vendor/symfony/src/Symfony/Component/HttpKernel/Event/GetResponseEvent.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony package.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * For the full copyright and license information, please view the LICENSE
       
     9  * file that was distributed with this source code.
       
    10  */
       
    11 
       
    12 namespace Symfony\Component\HttpKernel\Event;
       
    13 
       
    14 use Symfony\Component\HttpKernel\HttpKernelInterface;
       
    15 use Symfony\Component\HttpFoundation\Request;
       
    16 use Symfony\Component\HttpFoundation\Response;
       
    17 
       
    18 /**
       
    19  * Allows to create a response for a request
       
    20  *
       
    21  * Call setResponse() to set the response that will be returned for the
       
    22  * current request. The propagation of this event is stopped as soon as a
       
    23  * response is set.
       
    24  *
       
    25  * @author Bernhard Schussek <bernhard.schussek@symfony.com>
       
    26  *
       
    27  * @api
       
    28  */
       
    29 class GetResponseEvent extends KernelEvent
       
    30 {
       
    31     /**
       
    32      * The response object
       
    33      * @var Symfony\Component\HttpFoundation\Response
       
    34      */
       
    35     private $response;
       
    36 
       
    37     /**
       
    38      * Returns the response object
       
    39      *
       
    40      * @return Symfony\Component\HttpFoundation\Response
       
    41      *
       
    42      * @api
       
    43      */
       
    44     public function getResponse()
       
    45     {
       
    46         return $this->response;
       
    47     }
       
    48 
       
    49     /**
       
    50      * Sets a response and stops event propagation
       
    51      *
       
    52      * @param Symfony\Component\HttpFoundation\Response $response
       
    53      *
       
    54      * @api
       
    55      */
       
    56     public function setResponse(Response $response)
       
    57     {
       
    58         $this->response = $response;
       
    59 
       
    60         $this->stopPropagation();
       
    61     }
       
    62 
       
    63     /**
       
    64      * Returns whether a response was set
       
    65      *
       
    66      * @return Boolean Whether a response was set
       
    67      *
       
    68      * @api
       
    69      */
       
    70     public function hasResponse()
       
    71     {
       
    72         return null !== $this->response;
       
    73     }
       
    74 }