Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php
protected function buildItems()
    {
        $menuItems = [];
        $targetDimensionsToMatch = [];
        $allDimensionPresets = $this->configurationContentDimensionPresetSource->getAllPresets();
        $includeAllPresets = $this->getIncludeAllPresets();
        $pinnedDimensionValues = $this->getPresets();

        $pinnedDimensionName = $this->getDimension();
        if ($pinnedDimensionName !== null) {
            $targetDimensionsToMatch = $this->currentNode->getContext()->getTargetDimensions();
            unset($targetDimensionsToMatch[$pinnedDimensionName]);
        }

        foreach ($this->contentDimensionCombinator->getAllAllowedCombinations() as $allowedCombination) {
            $targetDimensions = $this->calculateTargetDimensionsForCombination($allowedCombination);

            if ($pinnedDimensionName !== null && is_array($pinnedDimensionValues)) {
                if (!in_array($targetDimensions[$pinnedDimensionName], $pinnedDimensionValues)) {
                    continue;
                }
            }

            // skip variants not matching the current target dimensions (except the dimension this menu covers)
            if ($targetDimensionsToMatch !== []) {
                foreach ($targetDimensionsToMatch as $dimensionName => $dimensionValue) {
                    if ($targetDimensions[$dimensionName] !== $dimensionValue) {
                        continue 2;
                    }
                }
            }

            $nodeInDimensions = $this->getNodeInDimensions($allowedCombination, $targetDimensions);

            // no match, so we look further...
            if ($nodeInDimensions === null && $includeAllPresets) {
                $nodeInDimensions = $this->findAcceptableNode($allowedCombination, $allDimensionPresets);
            }

            if ($nodeInDimensions !== null && ($this->isNodeHidden($nodeInDimensions) || $this->hasHiddenNodeParent($nodeInDimensions))) {
                $nodeInDimensions = null;
            }

            // determine metadata for target dimensions of node
            array_walk($targetDimensions, function (&$dimensionValue, $dimensionName, $allDimensionPresets) use ($pinnedDimensionName) {
                $dimensionValue = [
                    'value' => $dimensionValue,
                    'label' => $allDimensionPresets[$dimensionName]['presets'][$dimensionValue]['label'],
                    'isPinnedDimension' => ($pinnedDimensionName === null || $dimensionName == $pinnedDimensionName) ? true : false
                ];
            }, $allDimensionPresets);

            $menuItems[] = [
                'node' => $nodeInDimensions,
                'state' => $this->calculateItemState($nodeInDimensions),
                'label' => $this->itemLabel($pinnedDimensionName, $nodeInDimensions, $targetDimensions),
                'dimensions' => $allowedCombination,
                'targetDimensions' => $targetDimensions
            ];
        }

        // sort/limit according to configured "presets" if needed
        if ($pinnedDimensionName !== null && is_array($pinnedDimensionValues)) {
            $sortedMenuItems = [];
            foreach ($pinnedDimensionValues as $pinnedDimensionValue) {
                foreach ($menuItems as $menuItemKey => $menuItem) {
                    if ($menuItem['targetDimensions'][$pinnedDimensionName]['value'] === $pinnedDimensionValue) {
                        $sortedMenuItems[$menuItemKey] = $menuItem;
                    }
                }
            }

            return $sortedMenuItems;
        }

        return $menuItems;
    }
protected function buildItems()
    {
        $menuItems = [];
        $targetDimensionsToMatch = [];
        $allDimensionPresets = $this->configurationContentDimensionPresetSource->getAllPresets();
        $includeAllPresets = $this->getIncludeAllPresets();
        $pinnedDimensionValues = $this->getPresets();

        $pinnedDimensionName = $this->getDimension();
        if ($pinnedDimensionName !== null) {
            $targetDimensionsToMatch = $this->currentNode->getContext()->getTargetDimensions();
            unset($targetDimensionsToMatch[$pinnedDimensionName]);
        }

        foreach ($this->contentDimensionCombinator->getAllAllowedCombinations() as $allowedCombination) {
            $targetDimensions = $this->calculateTargetDimensionsForCombination($allowedCombination);

            if ($pinnedDimensionName !== null && is_array($pinnedDimensionValues)) {
                if (!in_array($targetDimensions[$pinnedDimensionName], $pinnedDimensionValues)) {
                    continue;
                }
            }

            // skip variants not matching the current target dimensions (except the dimension this menu covers)
            if ($targetDimensionsToMatch !== []) {
                foreach ($targetDimensionsToMatch as $dimensionName => $dimensionValue) {
                    if ($targetDimensions[$dimensionName] !== $dimensionValue) {
                        continue 2;
                    }
                }
            }

            $nodeInDimensions = $this->getNodeInDimensions($allowedCombination, $targetDimensions);

            // no match, so we look further...
            if ($nodeInDimensions === null && $includeAllPresets) {
                $nodeInDimensions = $this->findAcceptableNode($allowedCombination, $allDimensionPresets);
            }

            if ($nodeInDimensions !== null && ($this->isNodeHidden($nodeInDimensions) || $this->hasHiddenNodeParent($nodeInDimensions))) {
                $nodeInDimensions = null;
            }

            // determine metadata for target dimensions of node
            array_walk($targetDimensions, function (&$dimensionValue, $dimensionName, $allDimensionPresets) use ($pinnedDimensionName) {
                $dimensionValue = [
                    'value' => $dimensionValue,
                    'label' => $allDimensionPresets[$dimensionName]['presets'][$dimensionValue]['label'],
                    'isPinnedDimension' => ($pinnedDimensionName === null || $dimensionName == $pinnedDimensionName) ? true : false
                ];
            }, $allDimensionPresets);

            $menuItems[] = [
                'node' => $nodeInDimensions,
                'state' => $this->calculateItemState($nodeInDimensions),
                'label' => $this->itemLabel($pinnedDimensionName, $nodeInDimensions, $targetDimensions),
                'dimensions' => $allowedCombination,
                'targetDimensions' => $targetDimensions
            ];
        }

        // sort/limit according to configured "presets" if needed
        if ($pinnedDimensionName !== null && is_array($pinnedDimensionValues)) {
            $sortedMenuItems = [];
            foreach ($pinnedDimensionValues as $pinnedDimensionValue) {
                foreach ($menuItems as $menuItemKey => $menuItem) {
                    if ($menuItem['targetDimensions'][$pinnedDimensionName]['value'] === $pinnedDimensionValue) {
                        $sortedMenuItems[$menuItemKey] = $menuItem;
                    }
                }
            }

            return $sortedMenuItems;
        }

        return $menuItems;
    }
protected function buildItems ( ) { $ menuItems = [ ] ; $ targetDimensionsToMatch = [ ] ; $ allDimensionPresets = $ this -> configurationContentDimensionPresetSource -> getAllPresets ( ) ; $ includeAllPresets = $ this -> getIncludeAllPresets ( ) ; $ pinnedDimensionValues = $ this -> getPresets ( ) ; $ pinnedDimensionName = $ this -> getDimension ( ) ; if ( $ pinnedDimensionName !== null ) { $ targetDimensionsToMatch = $ this -> currentNode -> getContext ( ) -> getTargetDimensions ( ) ; unset ( $ targetDimensionsToMatch [ $ pinnedDimensionName ] ) ; } foreach ( $ this -> contentDimensionCombinator -> getAllAllowedCombinations ( ) as $ allowedCombination ) { $ targetDimensions = $ this -> calculateTargetDimensionsForCombination ( $ allowedCombination ) ; if ( $ pinnedDimensionName !== null && is_array ( $ pinnedDimensionValues ) ) { if ( ! in_array ( $ targetDimensions [ $ pinnedDimensionName ] , $ pinnedDimensionValues ) ) { continue ; } } // skip variants not matching the current target dimensions (except the dimension this menu covers) if ( $ targetDimensionsToMatch !== [ ] ) { foreach ( $ targetDimensionsToMatch as $ dimensionName => $ dimensionValue ) { if ( $ targetDimensions [ $ dimensionName ] !== $ dimensionValue ) { continue 2 ; } } } $ nodeInDimensions = $ this -> getNodeInDimensions ( $ allowedCombination , $ targetDimensions ) ; // no match, so we look further... if ( $ nodeInDimensions === null && $ includeAllPresets ) { $ nodeInDimensions = $ this -> findAcceptableNode ( $ allowedCombination , $ allDimensionPresets ) ; } if ( $ nodeInDimensions !== null && ( $ this -> isNodeHidden ( $ nodeInDimensions ) || $ this -> hasHiddenNodeParent ( $ nodeInDimensions ) ) ) { $ nodeInDimensions = null ; } // determine metadata for target dimensions of node array_walk ( $ targetDimensions , function ( & $ dimensionValue , $ dimensionName , $ allDimensionPresets ) use ( $ pinnedDimensionName ) { $ dimensionValue = [ 'value' => $ dimensionValue , 'label' => $ allDimensionPresets [ $ dimensionName ] [ 'presets' ] [ $ dimensionValue ] [ 'label' ] , 'isPinnedDimension' => ( $ pinnedDimensionName === null || $ dimensionName == $ pinnedDimensionName ) ? true : false ] ; } , $ allDimensionPresets ) ; $ menuItems [ ] = [ 'node' => $ nodeInDimensions , 'state' => $ this -> calculateItemState ( $ nodeInDimensions ) , 'label' => $ this -> itemLabel ( $ pinnedDimensionName , $ nodeInDimensions , $ targetDimensions ) , 'dimensions' => $ allowedCombination , 'targetDimensions' => $ targetDimensions ] ; } // sort/limit according to configured "presets" if needed if ( $ pinnedDimensionName !== null && is_array ( $ pinnedDimensionValues ) ) { $ sortedMenuItems = [ ] ; foreach ( $ pinnedDimensionValues as $ pinnedDimensionValue ) { foreach ( $ menuItems as $ menuItemKey => $ menuItem ) { if ( $ menuItem [ 'targetDimensions' ] [ $ pinnedDimensionName ] [ 'value' ] === $ pinnedDimensionValue ) { $ sortedMenuItems [ $ menuItemKey ] = $ menuItem ; } } } return $ sortedMenuItems ; } return $ menuItems ; }
Builds the array of Menu items for this variant menu
Builds the array of Menu items for this variant menu