Neos\Neos\Ui\TypoScript\ArrayCollectionImplementation::evaluate PHP Метод

evaluate() публичный Метод

Evaluate the collection nodes
public evaluate ( ) : string
Результат string
    public function evaluate()
    {
        $collection = $this->tsValue('collection');
        $output = [];
        if ($collection === null) {
            return [];
        }
        $this->numberOfRenderedNodes = 0;
        $itemName = $this->getItemName();
        $itemKey = $this->tsValue('itemKey');
        if ($itemName === null) {
            throw new \TYPO3\TypoScript\Exception('The Collection needs an itemName to be set.', 1344325771);
        }
        $iterationName = $this->getIterationName();
        $collectionTotalCount = count($collection);
        foreach ($collection as $collectionElementKey => $collectionElement) {
            $context = $this->tsRuntime->getCurrentContext();
            $context[$itemKey] = $collectionElementKey;
            $context[$itemName] = $collectionElement;
            if ($iterationName !== null) {
                $context[$iterationName] = $this->prepareIterationInformation($collectionTotalCount);
            }
            $this->tsRuntime->pushContextArray($context);
            if ($value = $this->tsRuntime->render($this->path . '/itemRenderer')) {
                if ($this->tsRuntime->canRender($this->path . '/itemKeyRenderer')) {
                    $key = $this->tsRuntime->render($this->path . '/itemKeyRenderer');
                    $output[$key] = $value;
                } else {
                    $output[] = $value;
                }
            }
            $this->tsRuntime->popContext();
            $this->numberOfRenderedNodes++;
        }
        return $output;
    }

Usage Example

 /**
  * Evaluate the collection nodes
  *
  * @return string
  * @throws TypoScriptException
  */
 public function evaluate()
 {
     $items = parent::evaluate();
     $collection = $this->tsValue('appendTo');
     return array_merge($collection, $items);
 }
ArrayCollectionImplementation