Ejemplo n.º 1
0
 /**
  * Generates and sets Cache Keys for current Route
  *
  * @param RequestInterface $request
  */
 public function setCacheKeys(RequestInterface $request)
 {
     $path = $request->getPath();
     $this->cacheKeys['route'] = md5($path . '_route_' . session_id());
     $this->cacheKeys['response'] = md5($path . '_response_' . session_id());
 }
Ejemplo n.º 2
0
 /**
  * Find matching Route from Route(s)
  *
  * @param array $routes
  * @param RequestInterface $request
  * @return mixed|null
  * @throws PageNotFoundException
  */
 protected function findRoute(array $routes, RequestInterface $request)
 {
     $path = $request->getPath();
     if (isset($routes[$path])) {
         $route = $routes[$path];
     } else {
         $route = DataCollection::find($routes, function ($key, $value) use($request) {
             return $value->isMatch($request);
         });
     }
     if (!$route instanceof Route) {
         throw new PageNotFoundException();
     } else {
         $this->dispatch('core.router.matched', $this);
     }
     return $route;
 }