/** * add a route * @param string $pattern * @param Closure|string $callback * @param null|string $routeName * @param array HTTP Methode * @return Application */ public function mount($pattern, $callback, $routeName = null, $methodes = array()) { $route = new Route(); $route->setPath($pattern)->setName($routeName)->setCallback($callback); $this->container['router']->mount($route, $methodes); return $this; }
protected function match(Request $request, Route $route) { $currentPath = $this->getCurrentPath($request); $routePath = $route->getPath(); $regex = $route->getRegularExpression(); if ($currentPath == $routePath) { return true; } else { if (!empty($regex) && preg_match('#^' . $regex . '\\/?$#', $currentPath, $matches)) { $request->query->add($route->getNamesParameters($matches)); return true; } } return false; }