Swat/SwatContainer.php
public function replace(SwatWidget $widget, SwatWidget $new_widget)
    {
        foreach ($this->children as $key => $child_widget) {
            if ($child_widget === $widget) {
                $this->children[$key] = $new_widget;
                $new_widget->parent = $this;
                $widget->parent = null;

                if ($widget->id !== null) {
                    unset($this->children_by_id[$widget->id]);
                }

                if ($new_widget->id !== null) {
                    $this->children_by_id[$new_widget->id] = $new_widget;
                }

                return $widget;
            }
        }
        return null;
    }
public function replace(SwatWidget $widget, SwatWidget $new_widget)
    {
        foreach ($this->children as $key => $child_widget) {
            if ($child_widget === $widget) {
                $this->children[$key] = $new_widget;
                $new_widget->parent = $this;
                $widget->parent = null;

                if ($widget->id !== null) {
                    unset($this->children_by_id[$widget->id]);
                }

                if ($new_widget->id !== null) {
                    $this->children_by_id[$new_widget->id] = $new_widget;
                }

                return $widget;
            }
        }
        return null;
    }
public function replace ( SwatWidget $ widget , SwatWidget $ new_widget ) { foreach ( $ this -> children as $ key => $ child_widget ) { if ( $ child_widget === $ widget ) { $ this -> children [ $ key ] = $ new_widget ; $ new_widget -> parent = $ this ; $ widget -> parent = null ; if ( $ widget -> id !== null ) { unset ( $ this -> children_by_id [ $ widget -> id ] ) ; } if ( $ new_widget -> id !== null ) { $ this -> children_by_id [ $ new_widget -> id ] = $ new_widget ; } return $ widget ; } } return null ; }
Replace a widget

Replaces a child widget in this container. The parent of the removed
widget is set to null.

@param SwatWidget $widget a reference to the widget to be replaced.
@param SwatWidget $widget a reference to the new widget.

@return SwatWidget a reference to the removed widget, or null if the
widget is not found.
Replace a widget