Neos.Fusion/Classes/FusionObjects/ReduceImplementation.php
public function evaluate()
    {
        $items = $this->getItems();
        $value = $this->getInitialValue();

        if ($items === null) {
            return $value;
        }
        $this->numberOfRenderedNodes = 0;
        $itemName = $this->getItemName();
        if ($itemName === null) {
            throw new FusionException('The Reduction needs an itemName to be set.', 1537890155);
        }
        $carryName = $this->getCarryName();
        if ($carryName === null) {
            throw new FusionException('The Reduction needs an carryName to be set.', 1537890148);
        }
        $itemKeyName = $this->getItemKey();
        $iterationName = $this->getIterationName();
        $collectionTotalCount = count($items);
        foreach ($items as $itemKey => $item) {
            $context = $this->runtime->getCurrentContext();
            $context[$itemName] = $item;
            $context[$carryName] = $value;
            if ($itemKeyName !== null) {
                $context[$itemKeyName] = $itemKey;
            }
            if ($iterationName !== null) {
                $context[$iterationName] = $this->prepareIterationInformation($collectionTotalCount);
            }
            $this->runtime->pushContextArray($context);
            $value = $this->runtime->render($this->path . '/itemReducer');
            $this->runtime->popContext();
            $this->numberOfRenderedNodes++;
        }
        return $value;
    }
public function evaluate()
    {
        $items = $this->getItems();
        $value = $this->getInitialValue();

        if ($items === null) {
            return $value;
        }
        $this->numberOfRenderedNodes = 0;
        $itemName = $this->getItemName();
        if ($itemName === null) {
            throw new FusionException('The Reduction needs an itemName to be set.', 1537890155);
        }
        $carryName = $this->getCarryName();
        if ($carryName === null) {
            throw new FusionException('The Reduction needs an carryName to be set.', 1537890148);
        }
        $itemKeyName = $this->getItemKey();
        $iterationName = $this->getIterationName();
        $collectionTotalCount = count($items);
        foreach ($items as $itemKey => $item) {
            $context = $this->runtime->getCurrentContext();
            $context[$itemName] = $item;
            $context[$carryName] = $value;
            if ($itemKeyName !== null) {
                $context[$itemKeyName] = $itemKey;
            }
            if ($iterationName !== null) {
                $context[$iterationName] = $this->prepareIterationInformation($collectionTotalCount);
            }
            $this->runtime->pushContextArray($context);
            $value = $this->runtime->render($this->path . '/itemReducer');
            $this->runtime->popContext();
            $this->numberOfRenderedNodes++;
        }
        return $value;
    }
public function evaluate ( ) { $ items = $ this -> getItems ( ) ; $ value = $ this -> getInitialValue ( ) ; if ( $ items === null ) { return $ value ; } $ this -> numberOfRenderedNodes = 0 ; $ itemName = $ this -> getItemName ( ) ; if ( $ itemName === null ) { throw new FusionException ( 'The Reduction needs an itemName to be set.' , 1537890155 ) ; } $ carryName = $ this -> getCarryName ( ) ; if ( $ carryName === null ) { throw new FusionException ( 'The Reduction needs an carryName to be set.' , 1537890148 ) ; } $ itemKeyName = $ this -> getItemKey ( ) ; $ iterationName = $ this -> getIterationName ( ) ; $ collectionTotalCount = count ( $ items ) ; foreach ( $ items as $ itemKey => $ item ) { $ context = $ this -> runtime -> getCurrentContext ( ) ; $ context [ $ itemName ] = $ item ; $ context [ $ carryName ] = $ value ; if ( $ itemKeyName !== null ) { $ context [ $ itemKeyName ] = $ itemKey ; } if ( $ iterationName !== null ) { $ context [ $ iterationName ] = $ this -> prepareIterationInformation ( $ collectionTotalCount ) ; } $ this -> runtime -> pushContextArray ( $ context ) ; $ value = $ this -> runtime -> render ( $ this -> path . '/itemReducer' ) ; $ this -> runtime -> popContext ( ) ; $ this -> numberOfRenderedNodes ++ ; } return $ value ; }
Reduce the given items to a single value

@return mixed
@throws FusionException
Reduce the given items to a single value