/** * Add the route to any look-up tables if necessary. * * @param \Viserio\Contracts\Routing\Route $route */ protected function addLookups(RouteContract $route) { // If the route has a name, we will add it to the name look-up table so that we // will quickly be able to find any route associate with a name and not have // to iterate through every route every time we need to perform a look-up. $action = $route->getAction(); if (isset($action['as'])) { $this->nameList[$action['as']] = $route; } // When the route is routing to a controller we will also store the action that // is used by the route. This will let us reverse route to controllers while // processing a request and easily generate URLs to the given controllers. if (isset($action['controller'])) { $this->actionList[trim($action['controller'], '\\')] = $route; } }
/** * Add the necessary where clauses to the route based on its initial registration. * * @param \Viserio\Contracts\Routing\Route $route * * @return \Viserio\Contracts\Routing\Route */ protected function addWhereClausesToRoute(RouteContract $route) : RouteContract { $where = $route->getAction()['where'] ?? []; $patern = array_merge($this->patterns, $where); foreach ($patern as $name => $value) { $route->where($name, $value); } return $route; }