Swat/SwatView.php
public function setSelection(SwatViewSelection $selection, $selector = null)
    {
        if ($selector === null) {
            if (count($this->selectors) > 0) {
                $selector = reset($this->selectors);
            } else {
                throw new SwatException(
                    'This view does not have any selectors.'
                );
            }
        } elseif (is_string($selector)) {
            if (isset($this->selectors[$selector])) {
                $selector = $this->selectors[$selector];
            } else {
                throw new SwatObjectNotFoundException(
                    'Selector with an id ' .
                        "of {$selector} does not exist in this view.",
                    0,
                    $selector
                );
            }
        } elseif (!($selector instanceof SwatViewSelector)) {
            throw new SwatInvalidClassException(
                'Specified object is not a SwatViewSelector object.',
                0,
                $selector
            );
        } elseif (!isset($this->selections[$selector->getId()])) {
            throw new SwatException(
                'Specified SwatViewSelector is not a selector of this view.'
            );
        }

        $this->selections[$selector->getId()] = $selection;
    }
public function setSelection(SwatViewSelection $selection, $selector = null)
    {
        if ($selector === null) {
            if (count($this->selectors) > 0) {
                $selector = reset($this->selectors);
            } else {
                throw new SwatException(
                    'This view does not have any selectors.'
                );
            }
        } elseif (is_string($selector)) {
            if (isset($this->selectors[$selector])) {
                $selector = $this->selectors[$selector];
            } else {
                throw new SwatObjectNotFoundException(
                    'Selector with an id ' .
                        "of {$selector} does not exist in this view.",
                    0,
                    $selector
                );
            }
        } elseif (!($selector instanceof SwatViewSelector)) {
            throw new SwatInvalidClassException(
                'Specified object is not a SwatViewSelector object.',
                0,
                $selector
            );
        } elseif (!isset($this->selections[$selector->getId()])) {
            throw new SwatException(
                'Specified SwatViewSelector is not a selector of this view.'
            );
        }

        $this->selections[$selector->getId()] = $selection;
    }
public function setSelection ( SwatViewSelection $ selection , $ selector = null ) { if ( $ selector === null ) { if ( count ( $ this -> selectors ) > 0 ) { $ selector = reset ( $ this -> selectors ) ; } else { throw new SwatException ( 'This view does not have any selectors.' ) ; } } elseif ( is_string ( $ selector ) ) { if ( isset ( $ this -> selectors [ $ selector ] ) ) { $ selector = $ this -> selectors [ $ selector ] ; } else { throw new SwatObjectNotFoundException ( 'Selector with an id ' . "of {$selector} does not exist in this view." , 0 , $ selector ) ; } } elseif ( ! ( $ selector instanceof SwatViewSelector ) ) { throw new SwatInvalidClassException ( 'Specified object is not a SwatViewSelector object.' , 0 , $ selector ) ; } elseif ( ! isset ( $ this -> selections [ $ selector -> getId ( ) ] ) ) { throw new SwatException ( 'Specified SwatViewSelector is not a selector of this view.' ) ; } $ this -> selections [ $ selector -> getId ( ) ] = $ selection ; }
Sets a selection of this view

Use by {@link SwatViewSelector} objects during the processing phase to
set the selection of this view for a particular selector.

This method may also be used to override the selection provided by a
selector.

@param SwatViewSelection $selection the selection object to set.
@param SwatViewSelector|string $selector optional. The view selector
object or the view selector
identifier for which to get
the selection. Use this
parameter if this view has
multiple selectors. By default,
the first selector in the view
is used.

@throws SwatObjectNotFoundException if the <i>$selector</i> parameter is
specified as a string and this view
does not contain a selector with the
given identifier.
@throws SwatInvalidClassException if the <i>$selector</i> parameter is
specified as an object that is not a
{@link SwatViewSelector}.
@throws SwatException if the <i>$selector</i> parameter is specified as
a SwatViewSelector but the selector does not
belong to this view.
@throws SwatException if the <i>$selector</i> parameter is specified and
this view has no selectors.
Sets a selection of this view