1 | <?php |
||
23 | abstract class Route implements RouteInterface |
||
24 | { |
||
25 | |||
26 | // /** will most likely need this for routing so pencilled it in for now |
||
27 | // * @type CommandBusInterface $command_bus |
||
28 | // */ |
||
29 | // protected $command_bus; |
||
30 | |||
31 | /** |
||
32 | * @var EE_Dependency_Map $dependency_map |
||
33 | */ |
||
34 | protected $dependency_map; |
||
35 | |||
36 | /** |
||
37 | * @var LoaderInterface $loader |
||
38 | */ |
||
39 | protected $loader; |
||
40 | |||
41 | /** |
||
42 | * @var RequestInterface $request |
||
43 | */ |
||
44 | protected $request; |
||
45 | |||
46 | /** |
||
47 | * @var RouteMatchSpecificationInterface $specification |
||
48 | */ |
||
49 | private $specification; |
||
50 | |||
51 | /** |
||
52 | * @var boolean $handled |
||
53 | */ |
||
54 | private $handled = false; |
||
55 | |||
56 | |||
57 | /** |
||
58 | * Route constructor. |
||
59 | * |
||
60 | * @param EE_Dependency_Map $dependency_map |
||
61 | * @param LoaderInterface $loader |
||
62 | * @param RequestInterface $request |
||
63 | * @param RouteMatchSpecificationInterface $specification |
||
64 | */ |
||
65 | public function __construct( |
||
76 | |||
77 | |||
78 | /** |
||
79 | * @since $VID:$ |
||
80 | */ |
||
81 | abstract protected function registerDependencies(); |
||
82 | |||
83 | |||
84 | /** |
||
85 | * implements logic required to run during request |
||
86 | * |
||
87 | * @return bool |
||
88 | * @since $VID:$ |
||
89 | */ |
||
90 | abstract protected function requestHandler(); |
||
91 | |||
92 | |||
93 | /** |
||
94 | * returns true if the current request matches this route |
||
95 | * child classes can override and use Request directly to match route with request |
||
96 | * or supply a RouteMatchSpecification class and just use the below |
||
97 | * |
||
98 | * @return bool |
||
99 | * @since $VID:$ |
||
100 | */ |
||
101 | public function matchesCurrentRequest() |
||
107 | |||
108 | |||
109 | /** |
||
110 | * @return bool |
||
111 | */ |
||
112 | final public function isHandled() |
||
116 | |||
117 | |||
118 | /** |
||
119 | * @param bool $handled |
||
120 | */ |
||
121 | private function setHandled($handled) |
||
125 | |||
126 | |||
127 | /** |
||
128 | * runs route requestHandler() if |
||
129 | * - route has not previously been handled |
||
130 | * - route specification matches for current request |
||
131 | * sets route handled property based on results returned by requestHandler() |
||
132 | * |
||
133 | * @return bool |
||
134 | * @throws DomainException |
||
135 | * @since $VID:$ |
||
136 | */ |
||
137 | final public function handleRequest() |
||
155 | } |
||
156 |