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:----Da4RqHQSYyHhu8YrTheqn4SOL3gZu4YwlHwjJqpqYfS0bT31WKIEYU+IP8rSbQOqE0kYkjh1589t47ILD1VUZxJa5nKW2rsopDkWH9s8++k8etd5fnKhemi6mc+qrf6ybJtLW5ThSNKGWmWfm0X6S7EEl+2MouKGOEHz3bBPbeD4R/B7lNiypHoh0sst5kX1JJvm59VyzaXR/QfLD/dgH9yAouD3DvDiGOkNeZ/ebkrl95NV6vr27kW78dezimPDQ1s9l6d95nfuw0a5AdCGNCOLkhH/4/Ff1ofO6WgD9rExSgkP8sZTZzw3KZ8XriMDYiyLKO/eYRSf8fCUqDXealOkISq3dO+9rFYa8SxUWbgaiWOtmrHNFaUlKtLeh6VkXYVJYFpoinpcAoiad9hM0A8wKWRS/D0JbWEwrQzx/syvZoOIic9KZP8lHfDGcqRQlDBBw+tRJ1/YpLXVbe2iYdTzJ+1/c4bw6TrzoLXEImDpmI4dFWLrIz/4gg3ZPztbG+ELw323ISsMTABWqilt9EOefy0wpWl2xpmBcNZ61fA/DEX0mIzksS4cGWZqKzo9XKInJOmQOY3xLzQcOyDJ+n8B8HPSw2EdBSb15MEOXMbNnSjXQt/XUW2AQRb4Gce1UfMagOwVn/lrXS5iyVbDaRB/lKWiNShTO/MfOKGKwWA=----ATTACHMENT:----NDE1MzExMTIxNTU0NDQxMiA2NTcwOTk2MzE1MDE3MzY2IDc5MzEzMjUzOTI5MTMxNTc=