Neos\Fusion\Core\Parser::setValueInObjectTree PHP Метод

setValueInObjectTree() защищенный Метод

Assigns a value to a node or a property in the object tree, specified by the object path array.
protected setValueInObjectTree ( array $objectPathArray, mixed $value, array &$objectTree = null ) : array
$objectPathArray array The object path, specifying the node / property to set
$value mixed The value to assign, is a non-array type or an array with __eelExpression etc.
$objectTree array The current (sub-) tree, used internally - don't specify!
Результат array The modified object tree
    protected function setValueInObjectTree(array $objectPathArray, $value, &$objectTree = null)
    {
        if ($objectTree === null) {
            $objectTree =& $this->objectTree;
        }
        $currentKey = array_shift($objectPathArray);
        if ((int) $currentKey > 0) {
            $currentKey = (int) $currentKey;
        }
        if (empty($objectPathArray)) {
            // last part of the iteration, setting the final value
            if (isset($objectTree[$currentKey]) && $value === null) {
                unset($objectTree[$currentKey]);
            } elseif (isset($objectTree[$currentKey]) && is_array($objectTree[$currentKey])) {
                if (is_array($value)) {
                    $objectTree[$currentKey] = Arrays::arrayMergeRecursiveOverrule($objectTree[$currentKey], $value);
                } else {
                    $objectTree[$currentKey]['__value'] = $value;
                    $objectTree[$currentKey]['__eelExpression'] = null;
                    $objectTree[$currentKey]['__objectType'] = null;
                }
            } else {
                $objectTree[$currentKey] = $value;
            }
        } else {
            // we still need to traverse further down
            if (isset($objectTree[$currentKey]) && !is_array($objectTree[$currentKey])) {
                // the element one-level-down is already defined, but it is NOT an array. So we need to convert the simple type to __value
                $objectTree[$currentKey] = array('__value' => $objectTree[$currentKey], '__eelExpression' => null, '__objectType' => null);
            } elseif (!isset($objectTree[$currentKey])) {
                $objectTree[$currentKey] = array();
            }
            $this->setValueInObjectTree($objectPathArray, $value, $objectTree[$currentKey]);
        }
        return $objectTree;
    }