Symfony\Component\Form\PropertyPath::updatePropertyPath PHP Method

updatePropertyPath() protected method

Recursive implementation of setValue()
protected updatePropertyPath ( object | array &$objectOrArray, integer $currentIndex, mixed $value )
$objectOrArray object | array The object or array to traverse
$currentIndex integer The current index in the property path
$value mixed The value to set at the end of the property path
    protected function updatePropertyPath(&$objectOrArray, $currentIndex, $value)
    {
        $property = $this->elements[$currentIndex];

        if ($currentIndex + 1 < $this->length) {
            if (is_object($objectOrArray)) {
                $nestedObject = $this->readProperty($objectOrArray, $currentIndex);
            }
            // arrays need to be treated separately (due to PHP bug?)
            // http://bugs.php.net/bug.php?id=52133
            else {
                if (!array_key_exists($property, $objectOrArray)) {
                    $objectOrArray[$property] = array();
                }

                $nestedObject =& $objectOrArray[$property];
            }

            $this->updatePropertyPath($nestedObject, $currentIndex + 1, $value);
        } else {
            $this->updateProperty($objectOrArray, $currentIndex, $value);
        }
    }