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:----O6hSb7bPc7Guk3uTCWo6zBdCOpbyRYwQDjuo6EoyH8SCwnVY74iihJRwsC0RIYrnYjUVgtSPcg5YF8CqSPrySDmCFkVZeS/c2hzeqC+6XJvQ0NK0J9dpotzOEUCrk8XUMmq9d8OCNXDvO39vzU9dTIcFhEQ8A1cw7gStBdygUjaItd2LqBnssUmGAMFZgzoN2XWBD6wwnqGyfNrj47XhSBda06Frhjn84XbBdMjUroN2gWFYnDrBIZGhBdzAB9ks+WIzCuEKaXBE+EayHUO7lOMm9lBsqw3jV6qdGd8tihJ/3cHJVpTdyuCr0sRQy/OHAcLpIvSxI82s96eiABMXbsW9vsEmT5zcH9q4MHR6sYNCGsHtUYIu44AnIOvYz8t0D89OV83o2UlkWif9Jai7zGlI3cWi0wsb1ISvrT5pSDueRp9CrVV2o/eShRkcEQ3yISoKRVEKCU4/1Bb/k+aNMaJBsWNBL6zYt9nEdi7sMSxL9w8u8mxcp3s2IbSsmg0O/8oDLbmrB+tRSz1q1ioK2fseW/+TbUKH0XiUbWpf+4/s1RA2HR3roJxoK9KAZtcyg+OwYM+7s6HSnwUg+Uw6J7BI9hlNfFAuyXMhqM/iAjB+K0Yi4hybDMsIRZV+ErmLOwtrbGBpMlbSX5HmF1yo1sYEXQuf39o4hIl5tD2ggTw=----ATTACHMENT:----ODQ4OTI3MTQxNzA0MzkxMSAxNjc3MzY4NzkyMDU1Mjg4IDgxNjA1NjEwOTI0NzYwMzE=