/** * Fill Router with all founded Routes. * This method will try first to search routes in cache. * * @return Router */ public function fill(Router $router) { $lastMod = $this->getMtime(); $data = $this->cache->fetch('routes'); if (!$data || $data['saveTime'] < $lastMod) { $data['saveTime'] = time(); $data['routes'] = $this->buildRoutes(); $this->cache->save('routes', $data); } foreach ($data['routes'] as $id => $route) { $router->addRoute($id, $route); } return $router; }
/** * Forward request to another action. * * @param string * @return mixed */ public function forward($routeId, array $params = []) { $class = $this->router->getRoute($routeId)->getAction(); $action = new $class($this->getContainer()); return $action->run($this->get('request')->setParams($params)); }