lib/Serializer/Normalizer/V1/CollectionResultNormalizer.php
private function normalizeResultItem(CmsItemInterface $resultItem, int $version, ?string $format = null, array $context = []): array
    {
        $collectionItem = null;
        $cmsItem = $resultItem;
        $isDynamic = true;

        if ($resultItem instanceof ManualItem) {
            $collectionItem = $resultItem->getCollectionItem();
            $cmsItem = $collectionItem->getCmsItem();
            $isDynamic = false;
        }

        $configuration = (function () use ($collectionItem, $version): Generator {
            $itemConfigs = $collectionItem !== null ? $collectionItem->getConfigs() : [];
            foreach ($itemConfigs as $configKey => $config) {
                yield $configKey => $this->buildVersionedValues($config->getParameters(), $version);
            }
        })();

        $data = [
            'id' => $collectionItem !== null ? $collectionItem->getId() : null,
            'collection_id' => $collectionItem !== null ? $collectionItem->getCollectionId() : null,
            'visible' => $collectionItem !== null ?
                $this->visibilityResolver->isVisible($collectionItem) :
                true,
            'is_dynamic' => $isDynamic,
            'value' => $cmsItem->getValue(),
            'value_type' => $cmsItem->getValueType(),
            'name' => $cmsItem->getName(),
            'cms_visible' => $cmsItem->isVisible(),
            'cms_url' => '',
            'config' => $this->normalizer->normalize($configuration, $format, $context),
        ];

        try {
            $data['cms_url'] = $this->urlGenerator->generate($cmsItem);
        } catch (ItemException $e) {
            // Do nothing
        }

        return $data;
    }
private function normalizeResultItem(CmsItemInterface $resultItem, int $version, ?string $format = null, array $context = []): array
    {
        $collectionItem = null;
        $cmsItem = $resultItem;
        $isDynamic = true;

        if ($resultItem instanceof ManualItem) {
            $collectionItem = $resultItem->getCollectionItem();
            $cmsItem = $collectionItem->getCmsItem();
            $isDynamic = false;
        }

        $configuration = (function () use ($collectionItem, $version): Generator {
            $itemConfigs = $collectionItem !== null ? $collectionItem->getConfigs() : [];
            foreach ($itemConfigs as $configKey => $config) {
                yield $configKey => $this->buildVersionedValues($config->getParameters(), $version);
            }
        })();

        $data = [
            'id' => $collectionItem !== null ? $collectionItem->getId() : null,
            'collection_id' => $collectionItem !== null ? $collectionItem->getCollectionId() : null,
            'visible' => $collectionItem !== null ?
                $this->visibilityResolver->isVisible($collectionItem) :
                true,
            'is_dynamic' => $isDynamic,
            'value' => $cmsItem->getValue(),
            'value_type' => $cmsItem->getValueType(),
            'name' => $cmsItem->getName(),
            'cms_visible' => $cmsItem->isVisible(),
            'cms_url' => '',
            'config' => $this->normalizer->normalize($configuration, $format, $context),
        ];

        try {
            $data['cms_url'] = $this->urlGenerator->generate($cmsItem);
        } catch (ItemException $e) {
            // Do nothing
        }

        return $data;
    }
private function normalizeResultItem ( CmsItemInterface $ resultItem , int $ version , ? string $ format = null , array $ context = [ ] ) : array { $ collectionItem = null ; $ cmsItem = $ resultItem ; $ isDynamic = true ; if ( $ resultItem instanceof ManualItem ) { $ collectionItem = $ resultItem -> getCollectionItem ( ) ; $ cmsItem = $ collectionItem -> getCmsItem ( ) ; $ isDynamic = false ; } $ configuration = ( function ( ) use ( $ collectionItem , $ version ) : Generator { $ itemConfigs = $ collectionItem !== null ? $ collectionItem -> getConfigs ( ) : [ ] ; foreach ( $ itemConfigs as $ configKey => $ config ) { yield $ configKey => $ this -> buildVersionedValues ( $ config -> getParameters ( ) , $ version ) ; } } ) ( ) ; $ data = [ 'id' => $ collectionItem !== null ? $ collectionItem -> getId ( ) : null , 'collection_id' => $ collectionItem !== null ? $ collectionItem -> getCollectionId ( ) : null , 'visible' => $ collectionItem !== null ? $ this -> visibilityResolver -> isVisible ( $ collectionItem ) : true , 'is_dynamic' => $ isDynamic , 'value' => $ cmsItem -> getValue ( ) , 'value_type' => $ cmsItem -> getValueType ( ) , 'name' => $ cmsItem -> getName ( ) , 'cms_visible' => $ cmsItem -> isVisible ( ) , 'cms_url' => '' , 'config' => $ this -> normalizer -> normalize ( $ configuration , $ format , $ context ) , ] ; try { $ data [ 'cms_url' ] = $ this -> urlGenerator -> generate ( $ cmsItem ) ; } catch ( ItemException $ e ) { // Do nothing } return $ data ; }
Normalizes the provided result item into an array.
Normalizes the provided result item into an array .