Commit | Line | Data |
---|---|---|
44d399bc S |
1 | <?php |
2 | /** | |
3 | * Zend Framework (http://framework.zend.com/) | |
4 | * | |
5 | * @link http://github.com/zendframework/zf2 for the canonical source repository | |
6 | * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | |
7 | * @license http://framework.zend.com/license/new-bsd New BSD License | |
8 | */ | |
9 | ||
10 | /** | |
11 | * @namespace | |
12 | */ | |
13 | namespace Zend\Mvc\Router\Console; | |
14 | ||
15 | use Traversable; | |
16 | use Zend\Console\Request as ConsoleRequest; | |
17 | use Zend\Filter\FilterChain; | |
18 | use Zend\Stdlib\RequestInterface as Request; | |
19 | use Zend\Validator\ValidatorChain; | |
20 | ||
21 | /** | |
22 | * Segment route. | |
23 | * | |
24 | * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | |
25 | * @license http://framework.zend.com/license/new-bsd New BSD License | |
26 | * @see http://guides.rubyonrails.org/routing.html | |
27 | */ | |
28 | class Catchall implements RouteInterface | |
29 | { | |
30 | /** | |
31 | * Parts of the route. | |
32 | * | |
33 | * @var array | |
34 | */ | |
35 | protected $parts; | |
36 | ||
37 | /** | |
38 | * Default values. | |
39 | * | |
40 | * @var array | |
41 | */ | |
42 | protected $defaults; | |
43 | ||
44 | /** | |
45 | * Parameters' name aliases. | |
46 | * | |
47 | * @var array | |
48 | */ | |
49 | protected $aliases; | |
50 | ||
51 | /** | |
52 | * List of assembled parameters. | |
53 | * | |
54 | * @var array | |
55 | */ | |
56 | protected $assembledParams = []; | |
57 | ||
58 | /** | |
59 | * @var ValidatorChain | |
60 | */ | |
61 | protected $validators; | |
62 | ||
63 | /** | |
64 | * @var FilterChain | |
65 | */ | |
66 | protected $filters; | |
67 | ||
68 | /** | |
69 | * Create a new simple console route. | |
70 | * | |
71 | * @param array $defaults | |
72 | * @return Catchall | |
73 | */ | |
74 | public function __construct(array $defaults = []) | |
75 | { | |
76 | $this->defaults = $defaults; | |
77 | } | |
78 | ||
79 | /** | |
80 | * factory(): defined by Route interface. | |
81 | * | |
82 | * @see \Zend\Mvc\Router\RouteInterface::factory() | |
83 | * @param array|Traversable $options | |
84 | * @return Simple | |
85 | */ | |
86 | public static function factory($options = []) | |
87 | { | |
88 | return new static(isset($options['defaults']) ? $options['defaults'] : []); | |
89 | } | |
90 | ||
91 | /** | |
92 | * match(): defined by Route interface. | |
93 | * | |
94 | * @see Route::match() | |
95 | * @param Request $request | |
96 | * @return RouteMatch | |
97 | */ | |
98 | public function match(Request $request) | |
99 | { | |
100 | if (!$request instanceof ConsoleRequest) { | |
101 | return; | |
102 | } | |
103 | ||
104 | return new RouteMatch($this->defaults); | |
105 | } | |
106 | ||
107 | /** | |
108 | * assemble(): Defined by Route interface. | |
109 | * | |
110 | * @see \Zend\Mvc\Router\RouteInterface::assemble() | |
111 | * @param array $params | |
112 | * @param array $options | |
113 | * @return mixed | |
114 | */ | |
115 | public function assemble(array $params = [], array $options = []) | |
116 | { | |
117 | $this->assembledParams = []; | |
118 | } | |
119 | ||
120 | /** | |
121 | * getAssembledParams(): defined by Route interface. | |
122 | * | |
123 | * @see RouteInterface::getAssembledParams | |
124 | * @return array | |
125 | */ | |
126 | public function getAssembledParams() | |
127 | { | |
128 | return $this->assembledParams; | |
129 | } | |
130 | } |