lib/Core/Mapper/CollectionMapper.php
public function mapQuery(PersistenceQuery $query, ?array $locales = null, bool $useMainLocale = true): Query
    {
        try {
            $queryType = $this->queryTypeRegistry->getQueryType($query->type);
        } catch (QueryTypeException $e) {
            $queryType = new NullQueryType($query->type);
        }

        $locales = is_array($locales) && count($locales) > 0 ? $locales : [$query->mainLocale];
        if ($useMainLocale && $query->alwaysAvailable) {
            $locales[] = $query->mainLocale;
        }

        $validLocales = array_unique(array_intersect($locales, $query->availableLocales));
        if (count($validLocales) === 0) {
            throw new NotFoundException('query', $query->id);
        }

        /** @var string $queryLocale */
        $queryLocale = array_values($validLocales)[0];
        $untranslatableParams = iterator_to_array(
            $this->parameterMapper->extractUntranslatableParameters(
                $queryType,
                $query->parameters[$query->mainLocale]
            )
        );

        $queryData = [
            'id' => $query->id,
            'status' => $query->status,
            'collectionId' => $query->collectionId,
            'queryType' => $queryType,
            'isTranslatable' => $query->isTranslatable,
            'mainLocale' => $query->mainLocale,
            'alwaysAvailable' => $query->alwaysAvailable,
            'availableLocales' => $query->availableLocales,
            'locale' => $queryLocale,
            'parameters' => iterator_to_array(
                $this->parameterMapper->mapParameters(
                    $queryType,
                    $untranslatableParams + $query->parameters[$queryLocale]
                )
            ),
        ];

        return Query::fromArray($queryData);
    }
public function mapQuery(PersistenceQuery $query, ?array $locales = null, bool $useMainLocale = true): Query
    {
        try {
            $queryType = $this->queryTypeRegistry->getQueryType($query->type);
        } catch (QueryTypeException $e) {
            $queryType = new NullQueryType($query->type);
        }

        $locales = is_array($locales) && count($locales) > 0 ? $locales : [$query->mainLocale];
        if ($useMainLocale && $query->alwaysAvailable) {
            $locales[] = $query->mainLocale;
        }

        $validLocales = array_unique(array_intersect($locales, $query->availableLocales));
        if (count($validLocales) === 0) {
            throw new NotFoundException('query', $query->id);
        }

        /** @var string $queryLocale */
        $queryLocale = array_values($validLocales)[0];
        $untranslatableParams = iterator_to_array(
            $this->parameterMapper->extractUntranslatableParameters(
                $queryType,
                $query->parameters[$query->mainLocale]
            )
        );

        $queryData = [
            'id' => $query->id,
            'status' => $query->status,
            'collectionId' => $query->collectionId,
            'queryType' => $queryType,
            'isTranslatable' => $query->isTranslatable,
            'mainLocale' => $query->mainLocale,
            'alwaysAvailable' => $query->alwaysAvailable,
            'availableLocales' => $query->availableLocales,
            'locale' => $queryLocale,
            'parameters' => iterator_to_array(
                $this->parameterMapper->mapParameters(
                    $queryType,
                    $untranslatableParams + $query->parameters[$queryLocale]
                )
            ),
        ];

        return Query::fromArray($queryData);
    }
public function mapQuery ( PersistenceQuery $ query , ? array $ locales = null , bool $ useMainLocale = true ) : Query { try { $ queryType = $ this -> queryTypeRegistry -> getQueryType ( $ query -> type ) ; } catch ( QueryTypeException $ e ) { $ queryType = new NullQueryType ( $ query -> type ) ; } $ locales = is_array ( $ locales ) && count ( $ locales ) > 0 ? $ locales : [ $ query -> mainLocale ] ; if ( $ useMainLocale && $ query -> alwaysAvailable ) { $ locales [ ] = $ query -> mainLocale ; } $ validLocales = array_unique ( array_intersect ( $ locales , $ query -> availableLocales ) ) ; if ( count ( $ validLocales ) === 0 ) { throw new NotFoundException ( 'query' , $ query -> id ) ; } /** @var string $queryLocale */ $ queryLocale = array_values ( $ validLocales ) [ 0 ] ; $ untranslatableParams = iterator_to_array ( $ this -> parameterMapper -> extractUntranslatableParameters ( $ queryType , $ query -> parameters [ $ query -> mainLocale ] ) ) ; $ queryData = [ 'id' => $ query -> id , 'status' => $ query -> status , 'collectionId' => $ query -> collectionId , 'queryType' => $ queryType , 'isTranslatable' => $ query -> isTranslatable , 'mainLocale' => $ query -> mainLocale , 'alwaysAvailable' => $ query -> alwaysAvailable , 'availableLocales' => $ query -> availableLocales , 'locale' => $ queryLocale , 'parameters' => iterator_to_array ( $ this -> parameterMapper -> mapParameters ( $ queryType , $ untranslatableParams + $ query -> parameters [ $ queryLocale ] ) ) , ] ; return Query :: fromArray ( $ queryData ) ; }
Builds the API query value from persistence one.

If not empty, the first available locale in $locales array will be returned.

If the query is always available and $useMainLocale is set to true,
query in main locale will be returned if none of the locales in $locales
array are found.

@throws \Netgen\BlockManager\Exception\NotFoundException If the query does not have any requested locales
Builds the API query value from persistence one .