/** * redirect to a route * * @param string $name * @throws RouteNotFoundException */ public function route($name = '') { $routes = AsCollector::getAs(); if (isset($routes[$name])) { $this->to($routes[$name]); } else { throw new RouteNotFoundException(sprintf('%s Route Not Found')); } }
/** * Add a route with type, uri and action parameters * * @param string|array $types * @param array $uri * @param array $action * @return $this */ private function addRoute($types = '', $uri, $action = []) { if (is_string($action)) { $action = ['_controller' => $action]; } if (is_array($action)) { if (isset($action['as'])) { AsCollector::addAs($action['as'], $uri); } } $types = (array) $types; foreach ($types as $type) { $type = mb_convert_case($type, MB_CASE_UPPER); $add = ['uri' => isset(static::$firing['when']) ? $this->createWhenUri($uri) : $uri, 'action' => $action]; // add group parameter to action variable if (isset(static::$firing['group'])) { $add['group'] = static::$firing['group']; } // add to collection static::$routes[$type][] = $add; } return $this; }