Swat/SwatWidget.php
public function replaceWithContainer(SwatContainer $container = null)
    {
        if ($this->parent === null) {
            throw new SwatException(
                'Widget does not have a parent, unable ' .
                    'to replace this widget with a container.'
            );
        }

        if ($container === null) {
            $container = new SwatContainer();
        }

        $parent = $this->parent;
        $parent->replace($this, $container);
        $container->add($this);

        return $container;
    }
public function replaceWithContainer(SwatContainer $container = null)
    {
        if ($this->parent === null) {
            throw new SwatException(
                'Widget does not have a parent, unable ' .
                    'to replace this widget with a container.'
            );
        }

        if ($container === null) {
            $container = new SwatContainer();
        }

        $parent = $this->parent;
        $parent->replace($this, $container);
        $container->add($this);

        return $container;
    }
public function replaceWithContainer ( SwatContainer $ container = null ) { if ( $ this -> parent === null ) { throw new SwatException ( 'Widget does not have a parent, unable ' . 'to replace this widget with a container.' ) ; } if ( $ container === null ) { $ container = new SwatContainer ( ) ; } $ parent = $ this -> parent ; $ parent -> replace ( $ this , $ container ) ; $ container -> add ( $ this ) ; return $ container ; }
Replace this widget with a new container

Replaces this widget in the widget tree with a new {@link SwatContainer},
then adds this widget to the new container.

@param SwatContainer $container optional container to use

@throws SwatException

@return SwatContainer a reference to the new container.
Replace this widget with a new container