1 | <?php namespace Comodojo\Dispatcher\Router; |
||
34 | class Table extends DispatcherClassModel { |
||
35 | |||
36 | 2 | public function __construct( |
|
37 | CacheManager $cache, |
||
38 | 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 | public function remove($route) { |
||
97 | |||
98 | $regex = $this->regex($route); |
||
99 | |||
100 | $routes = $this->routes; |
||
101 | |||
102 | if (isset($routes[$regex])) { |
||
103 | |||
104 | unset($routes[$regex]); |
||
105 | |||
106 | $this->routes = $routes; |
||
107 | |||
108 | return true; |
||
109 | |||
110 | } |
||
111 | |||
112 | return false; |
||
113 | |||
114 | } |
||
115 | |||
116 | public function defaultRoute() { |
||
121 | |||
122 | public function load($routes) { |
||
139 | |||
140 | 1 | private function readCache() { |
|
141 | |||
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 setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write 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.