public function generateUri($routeIdentifier, array $params = []) : string
    {
        if (empty($routeIdentifier)) {
            throw new \InvalidArgumentException(
                'Please provide a route identifier, otherwise a link cannot be created!'
            );
        }

        // try to find path for given $target
        $determinedRouteDefinition = null;
        /** @var array $routeDefinition */
        foreach ($this->routes as $routeDefinition) {
            $route = $routeDefinition['route'];

            $identifier = $this->getRouteIdentifier($route);
            if ($routeIdentifier === $identifier) {
                $determinedRouteDefinition = $routeDefinition;
                break;
            }
        }

        // when no path for the given $target can be found,
        // stop processing...
        if (null === $determinedRouteDefinition) {
            throw new \InvalidArgumentException(sprintf('No route found for identifier "%s"', $routeIdentifier));
        }

        $pathMatcher = $determinedRouteDefinition['pathMatcher'];
        $route = $determinedRouteDefinition['route'];

        $detectedParams = [];

        preg_match_all($pathMatcher, $route->getPath(), $detectedParams);

        $this->validateParams($route, $params, array_keys($this->mapParams($detectedParams)));
        $link = $route->getPath();

        foreach ($params as $name => $value) {
            $link = str_replace('[:' . $name . ']', urlencode((string) $value), $link);
        }

        return $link;
    }
public function generateUri($routeIdentifier, array $params = []) : string
    {
        if (empty($routeIdentifier)) {
            throw new \InvalidArgumentException(
                'Please provide a route identifier, otherwise a link cannot be created!'
            );
        }

        // try to find path for given $target
        $determinedRouteDefinition = null;
        /** @var array $routeDefinition */
        foreach ($this->routes as $routeDefinition) {
            $route = $routeDefinition['route'];

            $identifier = $this->getRouteIdentifier($route);
            if ($routeIdentifier === $identifier) {
                $determinedRouteDefinition = $routeDefinition;
                break;
            }
        }

        // when no path for the given $target can be found,
        // stop processing...
        if (null === $determinedRouteDefinition) {
            throw new \InvalidArgumentException(sprintf('No route found for identifier "%s"', $routeIdentifier));
        }

        $pathMatcher = $determinedRouteDefinition['pathMatcher'];
        $route = $determinedRouteDefinition['route'];

        $detectedParams = [];

        preg_match_all($pathMatcher, $route->getPath(), $detectedParams);

        $this->validateParams($route, $params, array_keys($this->mapParams($detectedParams)));
        $link = $route->getPath();

        foreach ($params as $name => $value) {
            $link = str_replace('[:' . $name . ']', urlencode((string) $value), $link);
        }

        return $link;
    }
{@inheritdoc}