private function createUrlByUrlParameters(
        Result $result,
        array $urlParameters
    ): array {
        foreach ($this->routesDictionary as $field => $route) {
            if (
                !isset($urlParameters[$field]) ||
                (
                    is_array($urlParameters[$field]) &&
                    1 !== count($urlParameters[$field])
                )
            ) {
                continue;
            }

            $value = is_array($urlParameters[$field])
                ? reset($urlParameters[$field])
                : $urlParameters[$field];

            if (!$result
                ->getAggregation($field)
                ->getAllElements()[$value] instanceof Counter) {
                continue;
            }

            unset($urlParameters[$field]);
            $path = $this
                ->router
                ->getRouteCollection()
                ->get($route)
                ->getPath();
            preg_match_all(
                '~\{(.+?)\}~',
                $path,
                $matches
            );

            return [
                'route' => urldecode($this
                    ->router
                    ->generate(
                        $route,
                        array_merge(
                            array_intersect_key(
                                $result
                                    ->getAggregation($field)
                                    ->getAllElements()[$value]
                                    ->getValues(),
                                array_flip($matches[1])
                            ),
                            $urlParameters
                        ),
                        UrlGeneratorInterface::ABSOLUTE_URL
                    )),
                'url_parameters' => $urlParameters,
                'template_path' => $path,
                'field' => $field,
            ];
        }

        return [
            'route' => urldecode($this
                ->router
                ->generate(
                    $this->routesDictionary['main'],
                    $urlParameters,
                    UrlGeneratorInterface::ABSOLUTE_URL
                )),
            'url_parameters' => $urlParameters,
            'template_path' => urldecode($this
                ->router
                ->generate(
                    $this->routesDictionary['main'],
                    [],
                    UrlGeneratorInterface::ABSOLUTE_URL
                )
            ),
            'field' => false,
        ];
    }
private function createUrlByUrlParameters(
        Result $result,
        array $urlParameters
    ): array {
        foreach ($this->routesDictionary as $field => $route) {
            if (
                !isset($urlParameters[$field]) ||
                (
                    is_array($urlParameters[$field]) &&
                    1 !== count($urlParameters[$field])
                )
            ) {
                continue;
            }

            $value = is_array($urlParameters[$field])
                ? reset($urlParameters[$field])
                : $urlParameters[$field];

            if (!$result
                ->getAggregation($field)
                ->getAllElements()[$value] instanceof Counter) {
                continue;
            }

            unset($urlParameters[$field]);
            $path = $this
                ->router
                ->getRouteCollection()
                ->get($route)
                ->getPath();
            preg_match_all(
                '~\{(.+?)\}~',
                $path,
                $matches
            );

            return [
                'route' => urldecode($this
                    ->router
                    ->generate(
                        $route,
                        array_merge(
                            array_intersect_key(
                                $result
                                    ->getAggregation($field)
                                    ->getAllElements()[$value]
                                    ->getValues(),
                                array_flip($matches[1])
                            ),
                            $urlParameters
                        ),
                        UrlGeneratorInterface::ABSOLUTE_URL
                    )),
                'url_parameters' => $urlParameters,
                'template_path' => $path,
                'field' => $field,
            ];
        }

        return [
            'route' => urldecode($this
                ->router
                ->generate(
                    $this->routesDictionary['main'],
                    $urlParameters,
                    UrlGeneratorInterface::ABSOLUTE_URL
                )),
            'url_parameters' => $urlParameters,
            'template_path' => urldecode($this
                ->router
                ->generate(
                    $this->routesDictionary['main'],
                    [],
                    UrlGeneratorInterface::ABSOLUTE_URL
                )
            ),
            'field' => false,
        ];
    }
private function createUrlByUrlParameters ( Result $ result , array $ urlParameters ) : array { foreach ( $ this -> routesDictionary as $ field => $ route ) { if ( ! isset ( $ urlParameters [ $ field ] ) || ( is_array ( $ urlParameters [ $ field ] ) && 1 !== count ( $ urlParameters [ $ field ] ) ) ) { continue ; } $ value = is_array ( $ urlParameters [ $ field ] ) ? reset ( $ urlParameters [ $ field ] ) : $ urlParameters [ $ field ] ; if ( ! $ result -> getAggregation ( $ field ) -> getAllElements ( ) [ $ value ] instanceof Counter ) { continue ; } unset ( $ urlParameters [ $ field ] ) ; $ path = $ this -> router -> getRouteCollection ( ) -> get ( $ route ) -> getPath ( ) ; preg_match_all ( '~\{(.+?)\}~' , $ path , $ matches ) ; return [ 'route' => urldecode ( $ this -> router -> generate ( $ route , array_merge ( array_intersect_key ( $ result -> getAggregation ( $ field ) -> getAllElements ( ) [ $ value ] -> getValues ( ) , array_flip ( $ matches [ 1 ] ) ) , $ urlParameters ) , UrlGeneratorInterface :: ABSOLUTE_URL ) ) , 'url_parameters' => $ urlParameters , 'template_path' => $ path , 'field' => $ field , ] ; } return [ 'route' => urldecode ( $ this -> router -> generate ( $ this -> routesDictionary [ 'main' ] , $ urlParameters , UrlGeneratorInterface :: ABSOLUTE_URL ) ) , 'url_parameters' => $ urlParameters , 'template_path' => urldecode ( $ this -> router -> generate ( $ this -> routesDictionary [ 'main' ] , [ ] , UrlGeneratorInterface :: ABSOLUTE_URL ) ) , 'field' => false , ] ; }
Generate url by query parameters.

Given a route dictionary, we should apply the first one encontered

@param Result $result
@param array  $urlParameters

@return string[]
Generate url by query parameters .