1 | <?php |
||
35 | class Route extends EventableExtensionCapableAbstract implements RouteInterface, HandlerAwareInterface |
||
36 | { |
||
37 | use HandlerAwareTrait; |
||
38 | |||
39 | /**#@+ |
||
40 | * Route related events |
||
41 | * |
||
42 | * @const |
||
43 | */ |
||
44 | |||
45 | // before executing handler on this route |
||
46 | const EVENT_BEFORE_HANDLER = 'route.handler.before'; |
||
47 | |||
48 | // after executing handler on this route |
||
49 | const EVENT_AFTER_HANDLER = 'route.handler.before'; |
||
50 | |||
51 | /**#@-*/ |
||
52 | |||
53 | /** |
||
54 | * pattern to match against |
||
55 | * |
||
56 | * @var string |
||
57 | * @access protected |
||
58 | */ |
||
59 | protected $pattern; |
||
60 | |||
61 | /** |
||
62 | * allowed http methods |
||
63 | * |
||
64 | * @var string[] |
||
65 | * @access protected |
||
66 | */ |
||
67 | protected $methods; |
||
68 | |||
69 | /** |
||
70 | * default values for placeholders in the pattern |
||
71 | * |
||
72 | * @var array |
||
73 | * @access protected |
||
74 | */ |
||
75 | protected $defaults = []; |
||
76 | |||
77 | /** |
||
78 | * Constructor |
||
79 | * |
||
80 | * @param string|string[] $httpMethod 'GET|POST' allowed for this route. |
||
81 | * @param string $pattern matching pattern |
||
82 | * @param mixed $handler for Status::OK status |
||
83 | * @param array $defaultValues default value for placeholders |
||
84 | * @throws LogicException if pattern malformed |
||
85 | * @access public |
||
86 | */ |
||
87 | public function __construct( |
||
98 | |||
99 | /** |
||
100 | * {@inheritDoc} |
||
101 | */ |
||
102 | public function setPattern(/*# string */ $pattern) |
||
115 | |||
116 | /** |
||
117 | * {@inheritDoc} |
||
118 | */ |
||
119 | public function getPattern()/*# : string */ |
||
123 | |||
124 | /** |
||
125 | * {@inheritDoc} |
||
126 | */ |
||
127 | public function setMethods($methods) |
||
134 | |||
135 | /** |
||
136 | * {@inheritDoc} |
||
137 | */ |
||
138 | public function getMethods()/*# : array */ |
||
142 | |||
143 | /** |
||
144 | * {@inheritDoc} |
||
145 | */ |
||
146 | public function setDefault(array $values) |
||
151 | |||
152 | /** |
||
153 | * {@inheritDoc} |
||
154 | */ |
||
155 | public function getDefault()/*# : array */ |
||
159 | |||
160 | /** |
||
161 | * Validate the pattern |
||
162 | * |
||
163 | * @param string $pattern |
||
164 | * @throws LogicException |
||
165 | * @access protected |
||
166 | */ |
||
167 | protected function validatePattern(/*# string */ $pattern) |
||
179 | |||
180 | /** |
||
181 | * Extract default values from the pattern |
||
182 | * |
||
183 | * @param string $pattern |
||
184 | * @return string |
||
185 | * @access protected |
||
186 | */ |
||
187 | protected function extractDefaultValues( |
||
203 | } |
||
204 |