src/ContainerSetPathCapableTrait.php
protected function _containerSetPath(&$container, $path, $value)
    {
        $path       = $this->_normalizeArray($path);
        $pathLength = count($path);

        if (!$pathLength) {
            throw $this->_createInvalidArgumentException($this->__('Path is empty'), null, null, $container);
        }

        if ($pathLength === 1) {
            $this->_containerSet($container, $path[0], $value);

            return;
        }

        $currentSegment = array_shift($path);
        if (is_array($container)) {
            $this->_containerSetPath($container[$currentSegment], $path, $value);
        } else {
            $childContainer = $this->_containerGet($container, $currentSegment);
            $this->_containerSetPath($childContainer, $path, $value);
        }
    }
protected function _containerSetPath(&$container, $path, $value)
    {
        $path       = $this->_normalizeArray($path);
        $pathLength = count($path);

        if (!$pathLength) {
            throw $this->_createInvalidArgumentException($this->__('Path is empty'), null, null, $container);
        }

        if ($pathLength === 1) {
            $this->_containerSet($container, $path[0], $value);

            return;
        }

        $currentSegment = array_shift($path);
        if (is_array($container)) {
            $this->_containerSetPath($container[$currentSegment], $path, $value);
        } else {
            $childContainer = $this->_containerGet($container, $currentSegment);
            $this->_containerSetPath($childContainer, $path, $value);
        }
    }
protected function _containerSetPath ( & $ container , $ path , $ value ) { $ path = $ this -> _normalizeArray ( $ path ) ; $ pathLength = count ( $ path ) ; if ( ! $ pathLength ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Path is empty' ) , null , null , $ container ) ; } if ( $ pathLength === 1 ) { $ this -> _containerSet ( $ container , $ path [ 0 ] , $ value ) ; return ; } $ currentSegment = array_shift ( $ path ) ; if ( is_array ( $ container ) ) { $ this -> _containerSetPath ( $ container [ $ currentSegment ] , $ path , $ value ) ; } else { $ childContainer = $ this -> _containerGet ( $ container , $ currentSegment ) ; $ this -> _containerSetPath ( $ childContainer , $ path , $ value ) ; } }
Sets data on the nested container.

@since [*next-version*]

@param array|ArrayAccess|stdClass|BaseContainerInterface $container The top container in the chain.
@param array|Traversable|stdClass                        $path      The list of path segments.
@param mixed                                             $value     The value to set by path.

@throws ContainerExceptionInterface If an error occurred while reading or writing from one of the containers in the chain.
@throws InvalidArgumentException    If one of the containers in the chain is invalid.
@throws NotFoundExceptionInterface  If one of the containers in the chain does not have the corresponding key.
@throws OutOfRangeException         If key in one of the containers in the chain is invalid.
Sets data on the nested container .