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\Request;
13 
14 use ICanBoogie\HTTP\DispatcherInterface;
15 use ICanBoogie\HTTP\Request;
16 use ICanBoogie\PrototypeTrait;
17 
18 /**
19  * The context of a request.
20  *
21  * This is a general purpose container used to store the objects and variables related to a
22  * request.
23  *
24  * @property-read Request $request The request associated with the context.
25  * @property DispatcherInterface $dispatcher The dispatcher currently dispatching the request.
26  */
27 class Context
28 {
29     use PrototypeTrait;
30 
31     /**
32      * The request the context belongs to.
33      *
34      * @var Request
35      */
36     private $request;
37 
38     protected function get_request()
39     {
40         return $this->request;
41     }
42 
43     /**
44      * The dispatcher currently dispatching the request.
45      *
46      * @var DispatcherInterface|null
47      */
48     private $dispatcher;
49 
50     /**
51      * Sets the dispatcher currently dispatching the request.
52      *
53      * @param DispatcherInterface|null $dispatcher
54      *
55      * @throws \InvalidArgumentException if the value is not null and does not implements {@link DispatcherInterface}.
56      */
57     protected function set_dispatcher($dispatcher)
58     {
59         if ($dispatcher !== null && !($dispatcher instanceof DispatcherInterface))
60         {
61             throw new \InvalidArgumentException('$dispatcher must be an instance of ICanBoogie\HTTP\DispatcherInterface. Given: ' . get_class($dispatcher) . '.');
62         }
63 
64         $this->dispatcher = $dispatcher;
65     }
66 
67     protected function get_dispatcher()
68     {
69         return $this->dispatcher;
70     }
71 
72     /**
73      * @param Request $request The request the context belongs to.
74      */
75     public function __construct(Request $request)
76     {
77         $this->request = $request;
78     }
79 }
80 
ICanBoogie/HTTP v2.4.0 API documentation generated by ApiGen