cccf01f3dabb42134fab85c7e660aeb6e600e234
[yaffs-website] / vendor / symfony / http-kernel / Event / KernelEvent.php
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\EventDispatcher\Event;
15 use Symfony\Component\HttpFoundation\Request;
16 use Symfony\Component\HttpKernel\HttpKernelInterface;
17
18 /**
19  * Base class for events thrown in the HttpKernel component.
20  *
21  * @author Bernhard Schussek <bschussek@gmail.com>
22  */
23 class KernelEvent extends Event
24 {
25     private $kernel;
26     private $request;
27     private $requestType;
28
29     /**
30      * @param HttpKernelInterface $kernel      The kernel in which this event was thrown
31      * @param Request             $request     The request the kernel is currently processing
32      * @param int                 $requestType The request type the kernel is currently processing; one of
33      *                                         HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST
34      */
35     public function __construct(HttpKernelInterface $kernel, Request $request, $requestType)
36     {
37         $this->kernel = $kernel;
38         $this->request = $request;
39         $this->requestType = $requestType;
40     }
41
42     /**
43      * Returns the kernel in which this event was thrown.
44      *
45      * @return HttpKernelInterface
46      */
47     public function getKernel()
48     {
49         return $this->kernel;
50     }
51
52     /**
53      * Returns the request the kernel is currently processing.
54      *
55      * @return Request
56      */
57     public function getRequest()
58     {
59         return $this->request;
60     }
61
62     /**
63      * Returns the request type the kernel is currently processing.
64      *
65      * @return int One of HttpKernelInterface::MASTER_REQUEST and
66      *             HttpKernelInterface::SUB_REQUEST
67      */
68     public function getRequestType()
69     {
70         return $this->requestType;
71     }
72
73     /**
74      * Checks if this is a master request.
75      *
76      * @return bool True if the request is a master request
77      */
78     public function isMasterRequest()
79     {
80         return HttpKernelInterface::MASTER_REQUEST === $this->requestType;
81     }
82 }