/**
  * Inject the UrlHelper instance with a RouteResult, if present as a request attribute.
  *
  * Injects the helper, and then dispatches the next middleware.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable $next
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $result = $request->getAttribute(RouteResult::class, false);
     if ($result instanceof RouteResult) {
         $this->helper->setRouteResult($result);
     }
     return $next($request, $response);
 }
 public function generateUrl($route = null, array $params = [], $absoluteUrl = false)
 {
     if (!$this->urlHelper) {
         $this->urlHelper = $this->container->get(UrlHelper::class);
     }
     $url = $this->urlHelper->generate($route, $params);
     if ($absoluteUrl !== true) {
         return $url;
     }
     return $this->generateServerUrl($url);
 }
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $uri = $request->getUri();
     $uriPath = $uri->getPath();
     $baseUrl = $this->baseUrlFinder->findBaseUrl($request->getServerParams(), $uriPath);
     $basePath = $this->detectBasePath($request->getServerParams(), $baseUrl);
     $request = $request->withAttribute(self::BASE_URL, $baseUrl);
     $request = $request->withAttribute(self::BASE_PATH, $basePath);
     if (!empty($baseUrl) && strpos($uriPath, $baseUrl) === 0) {
         $path = substr($uriPath, strlen($baseUrl));
         $path = '/' . ltrim($path, '/');
         $request = $request->withUri($uri->withPath($path));
     }
     if ($this->urlHelper) {
         $this->urlHelper->setBasePath($baseUrl);
     }
     if ($this->basePathHelper) {
         $this->basePathHelper->setBasePath($basePath);
     }
     return $next($request, $response);
 }
 /**
  * Generate a URL from either the currently matched route or the specfied route.
  *
  * @param null|string $route Name of route from which to generate URL.
  * @param array $params Route substitution parameters
  * @return string
  */
 public function generateUrl($route = null, array $params = [])
 {
     return $this->urlHelper->generate($route, $params);
 }
 /**
  * Render absolute url for a given named route
  *
  * Usage: {{ url('article_show', {'slug': 'article.slug'}) }}
  * Generates: http://example.com/article/article.slug
  *
  * @param null  $route
  * @param array $params
  *
  * @return string
  */
 public function renderUrl($route = null, $params = [])
 {
     return $this->serverUrlHelper->generate($this->urlHelper->generate($route, $params));
 }
 /**
  * Proxies to `Zend\Expressive\Helper\UrlHelper::generate()`
  *
  * @param string $route
  * @param array $params
  * @return string
  */
 public function __invoke($route = null, $params = [])
 {
     return $this->helper->generate($route, $params);
 }