public function match($path, Request $request = null) { if ($this->pattern === null) { $this->compile(); } if (isset($this->config['options']['via']) && $request !== null && $this->config['options']['via'] != $request->method()) { return false; } if (preg_match($this->pattern, $path, $matches) === 0) { return false; } preg_match_all('/:([a-z0-9_]+)/', $this->config['template'], $m); $sections = isset($m[1]) ? $m[1] : array(); $sections[] = 'extension'; $matches = array_intersect_key($matches, array_flip($sections)); $specialSections = array('controller', 'action', 'extension'); foreach ($specialSections as $key) { if (isset($matches[$key])) { $this->config['params'][$key] = $matches[$key]; unset($matches[$key]); } } return array_merge($this->config['params'], array('args' => $matches)); }