/** * @param Route $parent * @param array|Route $route * @param array $path * @param bool $start * @return array|Route * @throws \RuntimeException */ function __invoke(Route $parent, $route, array $path, $start = false) { if ($root = $parent->child($path[0])) { return $this($root, $route, array_slice($path, 1)); } isset($path[1]) && Exception::runtime('Parent route not found: ' . $route[Arg::NAME]); $route[Arg::NAME] = $path[0]; $start && empty($route[Arg::ROUTE]) && isset($route[Arg::NAME]) && ($route[Arg::ROUTE] = $route[Arg::NAME]); !$start && empty($route[Arg::ROUTE]) && ($route[Arg::ROUTE] = Arg::SEPARATOR . $path[0]); $route = $this->definition($route); $parent->add($path[0], $route); return $route; }
/** * @param $name * @return array|Route */ protected function config($name) { return $name === $this->route[Arg::NAME] ? $this->route : $this->route->child($name); }