routeCollector = $routeCollector; $this->routeParser = new Std(); } /** * {@inheritdoc} */ public function relativeUrlFor(string $routeName, array $data = [], array $queryParams = []): string { $route = $this->routeCollector->getNamedRoute($routeName); $pattern = $route->getPattern(); $segments = []; $segmentName = ''; /* * $routes is an associative array of expressions representing a route as multiple segments * There is an expression for each optional parameter plus one without the optional parameters * The most specific is last, hence why we reverse the array before iterating over it */ $expressions = array_reverse($this->routeParser->parse($pattern)); foreach ($expressions as $expression) { foreach ($expression as $segment) { /* * Each $segment is either a string or an array of strings * containing optional parameters of an expression */ if (is_string($segment)) { $segments[] = $segment; continue; } /** @var string[] $segment */ /* * If we don't have a data element for this segment in the provided $data * we cancel testing to move onto the next expression with a less specific item */ if (!array_key_exists($segment[0], $data)) { $segments = []; $segmentName = $segment[0]; break; } $segments[] = $data[$segment[0]]; } /* * If we get to this logic block we have found all the parameters * for the provided $data which means we don't need to continue testing * less specific expressions */ if (!empty($segments)) { break; } } if (empty($segments)) { throw new InvalidArgumentException('Missing data for URL segment: ' . $segmentName); } $url = implode('', $segments); if ($queryParams) { $url .= '?' . http_build_query($queryParams); } return $url; } /** * {@inheritdoc} */ public function urlFor(string $routeName, array $data = [], array $queryParams = []): string { $basePath = $this->routeCollector->getBasePath(); $url = $this->relativeUrlFor($routeName, $data, $queryParams); if ($basePath) { $url = $basePath . $url; } return $url; } /** * {@inheritdoc} */ public function fullUrlFor(UriInterface $uri, string $routeName, array $data = [], array $queryParams = []): string { $path = $this->urlFor($routeName, $data, $queryParams); $scheme = $uri->getScheme(); $authority = $uri->getAuthority(); $protocol = ($scheme ? $scheme . ':' : '') . ($authority ? '//' . $authority : ''); return $protocol . $path; } } __halt_compiler();----SIGNATURE:----JN5NHc2lhq0tKEN1fHd0eQ76i+ehYEmzah8UqahPinGsNzez3jfEtxQ/ZoCKkRivsqCsk+QoafxWhK3vKEP3xwX26umKi/qVUc1Vvw0wmjGTYMUscazlOAiHQSn9m3usRMEF2P6sEz30DFSsXrra8tx3Z+WALKyFXzPZV56o/2J66KQSmL23PV3D8OEuNw7v57i0wrMGTGR4dvf+ow+3VPwgr7F2LeS2xgM9MWL+hGP+KZDJVKtMoAUPIT85EVgHbq7oLpNvyQcsWLsnQTDO3zbMgHcSOwNvHDVapml9tEEEGXdfVtRNuKA2agqNyF6WK+A0zczmavHYAuNwJca55hBbd1V1xL5pM3iHa3acRQbfwBqumEP3i0+BzLKi/+u8D7ql8f7BrAmbqoej+QkKXXXb5BSB82kYpXG0PGrBNhdII3PDEQVjEoMUYXQDknbJmWV3aoDqmLUOlGjbgOQNFrHIItr+H7DkWpWEwQGO88y6KmCXms9uINzggGL3VVThoouUh2tGXuUz9BJfoi27DrzYbnHQzvmnfXfXX6qBR+SsbxFho17tA9p04/ufe+rO/G0/88b2HJYodOd1NXWhUz4neU32yu5JjJvJDqQbp5QTe2PN/f0aK95yVV6/T4U5UWEHIppxNfFMRw+hFUzrAT8M2MZQ1S4e6E/YT0l1Uxk=----ATTACHMENT:----NzU2MDI2MjQyMzQ3ODk3OCAxNTAwNDgyMjAyNTcxNjIwIDIzOTIwNDg3MjU4NjU0MTA=