ICanBoogie/HTTP v2.4.0
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • Exception
    • HTTP
      • Dispatcher
      • Headers
      • Request

Classes

  • ICanBoogie\Exception\RescueEvent
  • ICanBoogie\HTTP\CallableDispatcher
  • ICanBoogie\HTTP\Dispatcher
  • ICanBoogie\HTTP\Dispatcher\BeforeDispatchEvent
  • ICanBoogie\HTTP\Dispatcher\DispatchEvent
  • ICanBoogie\HTTP\File
  • ICanBoogie\HTTP\FileInfo
  • ICanBoogie\HTTP\FileList
  • ICanBoogie\HTTP\Headers
  • ICanBoogie\HTTP\Headers\CacheControl
  • ICanBoogie\HTTP\Headers\ContentDisposition
  • ICanBoogie\HTTP\Headers\ContentType
  • ICanBoogie\HTTP\Headers\Date
  • ICanBoogie\HTTP\Headers\Header
  • ICanBoogie\HTTP\Headers\HeaderParameter
  • ICanBoogie\HTTP\Helpers
  • ICanBoogie\HTTP\RedirectResponse
  • ICanBoogie\HTTP\Request
  • ICanBoogie\HTTP\Request\Context
  • ICanBoogie\HTTP\Response
  • ICanBoogie\HTTP\Status
  • ICanBoogie\HTTP\WeightedDispatcher

Interfaces

  • ICanBoogie\HTTP\DispatcherInterface
  • ICanBoogie\HTTP\Exception

Exceptions

  • ICanBoogie\HTTP\DispatcherNotDefined
  • ICanBoogie\HTTP\ForceRedirect
  • ICanBoogie\HTTP\MethodNotSupported
  • ICanBoogie\HTTP\NotFound
  • ICanBoogie\HTTP\ServiceUnavailable
  • ICanBoogie\HTTP\StatusCodeNotValid
 1 <?php
 2 
 3 /*
 4  * This file is part of the ICanBoogie package.
 5  *
 6  * (c) Olivier Laviale <olivier.laviale@gmail.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 ICanBoogie\HTTP\Dispatcher;
13 
14 use ICanBoogie\Event;
15 use ICanBoogie\HTTP\Dispatcher;
16 use ICanBoogie\HTTP\Request;
17 use ICanBoogie\HTTP\Response;
18 
19 /**
20  * Event class for the `ICanBoogie\HTTP\Dispatcher::dispatch:before` event.
21  *
22  * Third parties may use this event to provide a response to the request before the dispatchers
23  * are invoked. The event is usually used by third parties to redirect requests or provide cached
24  * responses.
25  *
26  * @property-read Request $request
27  * @property Response $response
28  */
29 class BeforeDispatchEvent extends Event
30 {
31     /**
32      * The request.
33      *
34      * @var Request
35      */
36     private $request;
37 
38     protected function get_request()
39     {
40         return $this->request;
41     }
42 
43     /**
44      * Reference to the response.
45      *
46      * @var Response
47      */
48     private $response;
49 
50     protected function get_response()
51     {
52         return $this->response;
53     }
54 
55     protected function set_response(Response $response = null)
56     {
57         $this->response = $response;
58     }
59 
60     /**
61      * The event is constructed with the type `dispatch:before`.
62      *
63      * @param Dispatcher $target
64      * @param Request $request
65      * @param Response|null $response Reference to the response.
66      */
67     public function __construct(Dispatcher $target, Request $request, Response &$response = null)
68     {
69         $this->request = $request;
70         $this->response = &$response;
71 
72         parent::__construct($target, 'dispatch:before');
73     }
74 }
75 
ICanBoogie/HTTP v2.4.0 API documentation generated by ApiGen