1 | <?php |
||
11 | class Url implements ConditionInterface { |
||
12 | const WILDCARD = '*'; |
||
13 | |||
14 | /** |
||
15 | * URL to check against |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $url = ''; |
||
20 | |||
21 | /** |
||
22 | * Regex to detect parameters in urls |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $url_regex = '~ |
||
27 | (?<=/) # lookbehind for a slash |
||
28 | (?:\{) # require opening curly brace |
||
29 | (?P<name>[a-z]\w*) # require a string starting with a-z and followed by any number of word characters for the parameter name |
||
30 | (?P<optional>\?)? # optionally allow the user to mark the parameter as option using literal ? |
||
31 | (?::(?P<regex>.*?))? # optionally allow the user to supply a regex to match the argument against |
||
32 | (?:\}) # require closing curly brace |
||
33 | (?=/) # lookahead for a slash |
||
34 | ~ix'; |
||
35 | |||
36 | /** |
||
37 | * Regex to detect valid parameters in url segments |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $parameter_regex = '[^/]+'; |
||
42 | |||
43 | /** |
||
44 | * Constructor |
||
45 | * |
||
46 | * @param string $url |
||
47 | */ |
||
48 | public function __construct( $url ) { |
||
55 | |||
56 | /** |
||
57 | * {@inheritDoc} |
||
58 | */ |
||
59 | public function satisfied( Request $request ) { |
||
68 | |||
69 | /** |
||
70 | * {@inheritDoc} |
||
71 | */ |
||
72 | public function getArguments( Request $request ) { |
||
90 | |||
91 | /** |
||
92 | * Return the url for this condition |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getUrl() { |
||
99 | |||
100 | /** |
||
101 | * Concatenate 2 url conditions into a new one |
||
102 | * |
||
103 | * @param Url $url |
||
104 | * @return Url |
||
105 | */ |
||
106 | public function concatenate( Url $url ) { |
||
109 | |||
110 | /** |
||
111 | * Return parameter names as defined in the url |
||
112 | * |
||
113 | * @param string $url |
||
114 | * @return string[] |
||
115 | */ |
||
116 | protected function getParameterNames( $url ) { |
||
121 | |||
122 | /** |
||
123 | * Return regex to test whether normal urls match the parameter-based one |
||
124 | * |
||
125 | * @param string $url |
||
126 | * @param boolean $wrap |
||
127 | * @return string |
||
128 | */ |
||
129 | public function getValidationRegex( $url, $wrap = true ) { |
||
165 | } |
||
166 |