public function addFilterValue(
        Result $result,
        string $filterName,
        string $value
    ): string {
        if (isset($this->routesCache[spl_object_hash($result)][$filterName])) {
            return str_replace(
                ['{id}', '{slug}'],
                $result->getAggregation($filterName)->getCounter($value)->getValues(),
                $this->routesCache[spl_object_hash($result)][$filterName]
            );
        }

        $urlParameters = $this->generateQueryUrlParameters($result, $filterName);
        if (
            !isset($urlParameters[$filterName]) ||
            !in_array($value, $urlParameters[$filterName])
        ) {
            $urlParameters[$filterName][] = $value;
        }

        $urlElements = $this->createUrlByUrlParameters(
            $result,
            $urlParameters
        );

        $templateRoute = in_array($urlElements['field'], [false, $filterName])
            ? $urlElements['template_path']
            : parse_url($urlElements['route'], PHP_URL_PATH);

        $filteredUrlParameters = $urlElements['url_parameters'];
        $routeQuery = parse_url($urlElements['route'], PHP_URL_QUERY);
        $route = rtrim("$templateRoute?$routeQuery", '?');
        if (isset($filteredUrlParameters[$filterName])) {
            $paremeterKey = array_search($value, $filteredUrlParameters[$filterName]);
            $route = str_replace(
                "{$filterName}[$paremeterKey]=$value",
                "{$filterName}[$paremeterKey]={id}",
                $route
            );
        }

        $this->routesCache[spl_object_hash($result)][$filterName] = $route;

        return $urlElements['route'];
    }
public function addFilterValue(
        Result $result,
        string $filterName,
        string $value
    ): string {
        if (isset($this->routesCache[spl_object_hash($result)][$filterName])) {
            return str_replace(
                ['{id}', '{slug}'],
                $result->getAggregation($filterName)->getCounter($value)->getValues(),
                $this->routesCache[spl_object_hash($result)][$filterName]
            );
        }

        $urlParameters = $this->generateQueryUrlParameters($result, $filterName);
        if (
            !isset($urlParameters[$filterName]) ||
            !in_array($value, $urlParameters[$filterName])
        ) {
            $urlParameters[$filterName][] = $value;
        }

        $urlElements = $this->createUrlByUrlParameters(
            $result,
            $urlParameters
        );

        $templateRoute = in_array($urlElements['field'], [false, $filterName])
            ? $urlElements['template_path']
            : parse_url($urlElements['route'], PHP_URL_PATH);

        $filteredUrlParameters = $urlElements['url_parameters'];
        $routeQuery = parse_url($urlElements['route'], PHP_URL_QUERY);
        $route = rtrim("$templateRoute?$routeQuery", '?');
        if (isset($filteredUrlParameters[$filterName])) {
            $paremeterKey = array_search($value, $filteredUrlParameters[$filterName]);
            $route = str_replace(
                "{$filterName}[$paremeterKey]=$value",
                "{$filterName}[$paremeterKey]={id}",
                $route
            );
        }

        $this->routesCache[spl_object_hash($result)][$filterName] = $route;

        return $urlElements['route'];
    }
public function addFilterValue ( Result $ result , string $ filterName , string $ value ) : string { if ( isset ( $ this -> routesCache [ spl_object_hash ( $ result ) ] [ $ filterName ] ) ) { return str_replace ( [ '{id}' , '{slug}' ] , $ result -> getAggregation ( $ filterName ) -> getCounter ( $ value ) -> getValues ( ) , $ this -> routesCache [ spl_object_hash ( $ result ) ] [ $ filterName ] ) ; } $ urlParameters = $ this -> generateQueryUrlParameters ( $ result , $ filterName ) ; if ( ! isset ( $ urlParameters [ $ filterName ] ) || ! in_array ( $ value , $ urlParameters [ $ filterName ] ) ) { $ urlParameters [ $ filterName ] [ ] = $ value ; } $ urlElements = $ this -> createUrlByUrlParameters ( $ result , $ urlParameters ) ; $ templateRoute = in_array ( $ urlElements [ 'field' ] , [ false , $ filterName ] ) ? $ urlElements [ 'template_path' ] : parse_url ( $ urlElements [ 'route' ] , PHP_URL_PATH ) ; $ filteredUrlParameters = $ urlElements [ 'url_parameters' ] ; $ routeQuery = parse_url ( $ urlElements [ 'route' ] , PHP_URL_QUERY ) ; $ route = rtrim ( "$templateRoute?$routeQuery" , '?' ) ; if ( isset ( $ filteredUrlParameters [ $ filterName ] ) ) { $ paremeterKey = array_search ( $ value , $ filteredUrlParameters [ $ filterName ] ) ; $ route = str_replace ( "{$filterName}[$paremeterKey]=$value" , "{$filterName}[$paremeterKey]={id}" , $ route ) ; } $ this -> routesCache [ spl_object_hash ( $ result ) ] [ $ filterName ] = $ route ; return $ urlElements [ 'route' ] ; }
Add filter into query.

@param Result $result
@param string $filterName
@param string $value

@return string
Add filter into query .