1 | <?php namespace Comodojo\Dispatcher\Router; |
||
34 | class Table extends DispatcherClassModel { |
||
35 | |||
36 | 2 | public function __construct( |
|
37 | Cache $cache, |
||
38 | 1 | Router $router |
|
39 | 1 | ) { |
|
40 | |||
41 | 2 | parent::__construct($router->configuration, $router->logger); |
|
42 | |||
43 | 2 | $this->routes = array(); |
|
44 | |||
45 | 2 | $this->router = $router; |
|
46 | |||
47 | 2 | $this->parser = new Parser($this->logger); |
|
48 | |||
49 | 2 | $this->cache = $cache; |
|
50 | |||
51 | 1 | $this->readCache(); |
|
52 | |||
53 | 1 | } |
|
54 | |||
55 | 1 | public function add($route, $type, $class, $parameters = array()) { |
|
56 | |||
57 | 1 | $routeData = $this->get($route); |
|
58 | |||
59 | 1 | if (!is_null($routeData)) { |
|
60 | |||
61 | 1 | $routeData->setType($type) |
|
62 | ->setClassName($class) |
||
63 | ->setParameters($parameters); |
||
64 | |||
65 | } else { |
||
66 | |||
67 | 1 | $folders = explode("/", $route); |
|
68 | |||
69 | 1 | $this->register($folders, $type, $class, $parameters); |
|
70 | |||
71 | } |
||
72 | |||
73 | 1 | return $this; |
|
74 | |||
75 | } |
||
76 | |||
77 | 1 | public function get($route) { |
|
78 | |||
79 | 1 | $regex = $this->regex($route); |
|
80 | |||
81 | 1 | if (isset($this->routes[$regex])) |
|
82 | 1 | return $this->routes[$regex]; |
|
83 | else |
||
84 | 1 | return null; |
|
85 | |||
86 | } |
||
87 | |||
88 | 1 | public function regex($route) { |
|
95 | |||
96 | 1 | public function remove($route) { |
|
115 | |||
116 | public function defaultRoute() { |
||
121 | |||
122 | public function load($routes) { |
||
139 | |||
140 | 1 | private function readCache() { |
|
141 | |||
142 | 1 | if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
143 | |||
144 | $this->routes = $this->cache->setNamespace('dispatcherinternals')->get("dispatcher-routes"); |
||
145 | |||
146 | if (is_null($this->routes)) { |
||
147 | |||
148 | $this->routes = array(); |
||
149 | |||
150 | return; |
||
151 | |||
152 | } |
||
153 | |||
154 | $this->logger->debug("Routing table loaded from cache"); |
||
155 | |||
156 | } |
||
157 | |||
158 | private function dumpCache() { |
||
169 | |||
170 | // This method add a route to the supported list |
||
171 | 1 | private function register($folders, $type, $class, $parameters) { |
|
195 | |||
196 | } |
||
197 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.