matcher = new DefaultRouteMatcher($routeOrRouteMatcher, $constraints, $defaults, $aliases); } elseif ($routeOrRouteMatcher instanceof RouteMatcherInterface) { $this->matcher = $routeOrRouteMatcher; } else { throw new Exception\InvalidArgumentException( "routeOrRouteMatcher should either be string, or class implementing RouteMatcherInterface. " . gettype($routeOrRouteMatcher) . " was given." ); } } /** * factory(): defined by Route interface. * * @see \Zend\Mvc\Router\RouteInterface::factory() * @param array|Traversable $options * @throws Exception\InvalidArgumentException * @return self */ public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['route'])) { throw new Exception\InvalidArgumentException('Missing "route" in options array'); } foreach (array( 'constraints', 'defaults', 'aliases', ) as $opt) { if (!isset($options[$opt])) { $options[$opt] = array(); } } if (!isset($options['validators'])) { $options['validators'] = null; } if (!isset($options['filters'])) { $options['filters'] = null; } return new static( $options['route'], $options['constraints'], $options['defaults'], $options['aliases'], $options['filters'], $options['validators'] ); } /** * match(): defined by Route interface. * * @see Route::match() * @param Request $request * @param null|int $pathOffset * @return RouteMatch */ public function match(Request $request, $pathOffset = null) { if (!$request instanceof ConsoleRequest) { return; } $params = $request->getParams()->toArray(); $matches = $this->matcher->match($params); if (null !== $matches) { return new RouteMatch($matches); } return; } /** * assemble(): Defined by Route interface. * * @see \Zend\Mvc\Router\RouteInterface::assemble() * @param array $params * @param array $options * @return mixed */ public function assemble(array $params = array(), array $options = array()) { $this->assembledParams = array(); } /** * getAssembledParams(): defined by Route interface. * * @see RouteInterface::getAssembledParams * @return array */ public function getAssembledParams() { return $this->assembledParams; } }