2043a01758ce823e35a485ced1b6e3122fe27513
[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\HttpKernel\HttpKernelInterface;
15 use Symfony\Component\HttpFoundation\Request;
16 use Symfony\Component\EventDispatcher\Event;
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     /**
26      * The kernel in which this event was thrown.
27      *
28      * @var HttpKernelInterface
29      */
30     private $kernel;
31
32     /**
33      * The request the kernel is currently processing.
34      *
35      * @var Request
36      */
37     private $request;
38
39     /**
40      * The request type the kernel is currently processing.  One of
41      * HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST.
42      *
43      * @var int
44      */
45     private $requestType;
46
47     public function __construct(HttpKernelInterface $kernel, Request $request, $requestType)
48     {
49         $this->kernel = $kernel;
50         $this->request = $request;
51         $this->requestType = $requestType;
52     }
53
54     /**
55      * Returns the kernel in which this event was thrown.
56      *
57      * @return HttpKernelInterface
58      */
59     public function getKernel()
60     {
61         return $this->kernel;
62     }
63
64     /**
65      * Returns the request the kernel is currently processing.
66      *
67      * @return Request
68      */
69     public function getRequest()
70     {
71         return $this->request;
72     }
73
74     /**
75      * Returns the request type the kernel is currently processing.
76      *
77      * @return int One of HttpKernelInterface::MASTER_REQUEST and
78      *             HttpKernelInterface::SUB_REQUEST
79      */
80     public function getRequestType()
81     {
82         return $this->requestType;
83     }
84
85     /**
86      * Checks if this is a master request.
87      *
88      * @return bool True if the request is a master request
89      */
90     public function isMasterRequest()
91     {
92         return HttpKernelInterface::MASTER_REQUEST === $this->requestType;
93     }
94 }