| @@ 29-112 (lines=84) @@ | ||
| 26 | * @property-read Request $request |
|
| 27 | * @property Response|null $response |
|
| 28 | */ |
|
| 29 | class RescueEvent extends Event |
|
| 30 | { |
|
| 31 | const TYPE = 'rescue'; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * Reference to the exception to throw if the rescue fails. |
|
| 35 | * |
|
| 36 | * @var \Exception |
|
| 37 | */ |
|
| 38 | private $exception; |
|
| 39 | ||
| 40 | /** |
|
| 41 | * @return \Exception |
|
| 42 | */ |
|
| 43 | protected function get_exception() |
|
| 44 | { |
|
| 45 | return $this->exception; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @param \Exception $exception |
|
| 50 | * |
|
| 51 | * @return \Exception |
|
| 52 | */ |
|
| 53 | protected function set_exception(\Exception $exception) |
|
| 54 | { |
|
| 55 | return $this->exception = $exception; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * The request. |
|
| 60 | * |
|
| 61 | * @var Request |
|
| 62 | */ |
|
| 63 | private $request; |
|
| 64 | ||
| 65 | /** |
|
| 66 | * @return Request |
|
| 67 | */ |
|
| 68 | protected function get_request() |
|
| 69 | { |
|
| 70 | return $this->request; |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * Reference to the response that rescue the route. |
|
| 75 | * |
|
| 76 | * @var Response |
|
| 77 | */ |
|
| 78 | private $response; |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @return Response|null |
|
| 82 | */ |
|
| 83 | protected function get_response() |
|
| 84 | { |
|
| 85 | return $this->response; |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @param Response|null $response |
|
| 90 | */ |
|
| 91 | protected function set_response(Response $response = null) |
|
| 92 | { |
|
| 93 | $this->response = $response; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * The event is constructed with the type {@link self::TYPE}. |
|
| 98 | * |
|
| 99 | * @param Route $target |
|
| 100 | * @param \Exception $exception Reference to the exception thrown while dispatching the route. |
|
| 101 | * @param Request $request |
|
| 102 | * @param Response|null $response |
|
| 103 | */ |
|
| 104 | public function __construct(Route $target, \Exception &$exception, Request $request, Response &$response = null) |
|
| 105 | { |
|
| 106 | $this->exception = &$exception; |
|
| 107 | $this->request = $request; |
|
| 108 | $this->response = &$response; |
|
| 109 | ||
| 110 | parent::__construct($target, self::TYPE); |
|
| 111 | } |
|
| 112 | } |
|
| 113 | ||
| @@ 31-104 (lines=74) @@ | ||
| 28 | * @property-read Request $request |
|
| 29 | * @property Response $response |
|
| 30 | */ |
|
| 31 | class BeforeDispatchEvent extends Event |
|
| 32 | { |
|
| 33 | const TYPE = 'dispatch:before'; |
|
| 34 | ||
| 35 | /** |
|
| 36 | * The route. |
|
| 37 | * |
|
| 38 | * @var Route |
|
| 39 | */ |
|
| 40 | private $route; |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @return Route |
|
| 44 | */ |
|
| 45 | protected function get_route() |
|
| 46 | { |
|
| 47 | return $this->route; |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * The HTTP request. |
|
| 52 | * |
|
| 53 | * @var Request |
|
| 54 | */ |
|
| 55 | private $request; |
|
| 56 | ||
| 57 | /** |
|
| 58 | * @return Request |
|
| 59 | */ |
|
| 60 | protected function get_request() |
|
| 61 | { |
|
| 62 | return $this->request; |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Reference to the HTTP response. |
|
| 67 | * |
|
| 68 | * @var Response|null |
|
| 69 | */ |
|
| 70 | private $response; |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @return Response|null |
|
| 74 | */ |
|
| 75 | protected function get_response() |
|
| 76 | { |
|
| 77 | return $this->response; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @param Response|null $response |
|
| 82 | */ |
|
| 83 | protected function set_response(Response &$response = null) |
|
| 84 | { |
|
| 85 | $this->response = $response; |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * The event is constructed with the type {@link self::TYPE}. |
|
| 90 | * |
|
| 91 | * @param RouteDispatcher $target |
|
| 92 | * @param Route $route |
|
| 93 | * @param Request $request |
|
| 94 | * @param Response|null $response |
|
| 95 | */ |
|
| 96 | public function __construct(RouteDispatcher $target, Route $route, Request $request, Response &$response = null) |
|
| 97 | { |
|
| 98 | $this->route = $route; |
|
| 99 | $this->request = $request; |
|
| 100 | $this->response = &$response; |
|
| 101 | ||
| 102 | parent::__construct($target, self::TYPE); |
|
| 103 | } |
|
| 104 | } |
|
| 105 | ||
| @@ 29-90 (lines=62) @@ | ||
| 26 | * @property-read Request $request |
|
| 27 | * @property Response $response |
|
| 28 | */ |
|
| 29 | class DispatchEvent extends Event |
|
| 30 | { |
|
| 31 | const TYPE = 'dispatch'; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * The route. |
|
| 35 | * |
|
| 36 | * @var Route |
|
| 37 | */ |
|
| 38 | private $route; |
|
| 39 | ||
| 40 | protected function get_route() |
|
| 41 | { |
|
| 42 | return $this->route; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * The HTTP request. |
|
| 47 | * |
|
| 48 | * @var Request |
|
| 49 | */ |
|
| 50 | private $request; |
|
| 51 | ||
| 52 | protected function get_request() |
|
| 53 | { |
|
| 54 | return $this->request; |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Reference to the HTTP response. |
|
| 59 | * |
|
| 60 | * @var Response |
|
| 61 | */ |
|
| 62 | private $response; |
|
| 63 | ||
| 64 | protected function get_response() |
|
| 65 | { |
|
| 66 | return $this->response; |
|
| 67 | } |
|
| 68 | ||
| 69 | protected function set_response(Response $response = null) |
|
| 70 | { |
|
| 71 | $this->response = $response; |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * The event is constructed with the type `dispatch`. |
|
| 76 | * |
|
| 77 | * @param RouteDispatcher $target |
|
| 78 | * @param Route $route |
|
| 79 | * @param Request $request |
|
| 80 | * @param Response|null $response |
|
| 81 | */ |
|
| 82 | public function __construct(RouteDispatcher $target, Route $route, Request $request, Response &$response = null) |
|
| 83 | { |
|
| 84 | $this->route = $route; |
|
| 85 | $this->request = $request; |
|
| 86 | $this->response = &$response; |
|
| 87 | ||
| 88 | parent::__construct($target, self::TYPE); |
|
| 89 | } |
|
| 90 | } |
|
| 91 | ||