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:----fRBJyiex1nrlsG6Qy2pduWhjQZ639T1eKwIO5le/meDxGXXvpm9Fzbj7bJ5+uundBJcvLq3K7YgAnGaIEIzYXQSyVP3+KMTlwf5GwAtghcQxIZS6JttXR4mdx9A3owPJSuzA1X01djhdgvHS1+yZgNHxzCbHmEuhVh2mHfD154W5CF7N9Ovq3l35E0htC0yJhtHxAVdSRvNhuBMvuyV0679jZTcl0CGaazPCHiLzkL3rOmxtJnZhOEeQQHAdm+XOLiKj4+bUdVYg5RDPnMouSRhPaDV65qDQ3EAU50snzkuIKEpMERHpwZ/eLeG8S1bk7zGAS+o6zIrR9YUZHhG4RZNxCb8TRgFqC7qDX6MSvHW1qxjP8SV1TBK+CJFHGYecHfspRre6xn7Xe/kIzgZ/jifhTzDc+TfPbi+qes6M1Xaf8S7O9Ho/T3zhs0G4IbzhdUWcIT0GFHtp2c22oSjItXKXKH/f+btPAfqE7mIDcr+7IM71bP6Vj4p/CuWzMHLc1mQmeU27V5ybdfkgRdBygKkQ9egN8VB0bMVxxpX/CTWMqotJwRWsUoKLC/+s8v38rpc527JdgWaCMswBJT/E1sswg3vHuaQzZ6b0rFlNk2R3CvW7DshVfnLG87DuABBAvFpDwn6FJOX/nM7KHYyNiecp/obecynJHR1IFP5F49s=----ATTACHMENT:----NDcyNzc2NzAwMTUwMTQ2OCAzNzE0NDkyNzk2NDI5MTAxIDk1NTU2OTUzOTI3MDkzODI=