/** * @param array $parts * @param array $routes */ private function resolve(array $parts, $routes = []) { if (count($parts)) { $part = array_shift($parts); if (isset($routes[$part])) { $matchPart = $part; } elseif (isset($routes)) { foreach (array_keys($routes) as $rout) { if (strpos($rout, ':') === 0) { $matchPart = $rout; $param = mb_strcut($matchPart, 1); $this->params[$param] = $part; break; } } } if (isset($matchPart)) { $match = $routes[$matchPart]; $url = '/' . $matchPart; if (isset($match['name'])) { $this->getBreadcrumbs()->append(['url' => $url, 'name' => $match['name'], 'title' => $match['name']]); } if (isset($match['module'])) { $this->moduleName = $match['module']; } if (isset($match['controller'])) { $this->controller = $match['controller']; } if (isset($match['action'])) { $this->action = $match['action']; } } else { if (count($parts)) { $value = array_shift($parts); $this->params->offsetSet($part, $value); } else { $this->notFound(); } $match = []; } $this->resolve($parts, isset($match['children']) ? $match['children'] : []); } }
/** * @param $index * @param Tag $tag * @return $this */ public function set($index, Tag $tag) { $this->elements->offsetSet($index, $tag); return $this; }