public function setParents(array $parents)
    {
        $ownclass = get_class($this);
        $is_root = ($this->id === static::$root);

        $this->parents = array();
        foreach ($parents as $parent)
        {
            if (is_object($parent) && get_class($parent) == $ownclass)
                $this->parents[$parent->id] = $parent;
            elseif (is_scalar($parent))
                $this->parents[$parent] = null;
            else
                throw new Exception("Parent-ID must be a " . $ownclass . " object or a scalar");
        }

        if (empty($this->parents) && !$is_root)
            $this->parents = [$this->getRoot()];

        return $this;
    }
public function setParents(array $parents)
    {
        $ownclass = get_class($this);
        $is_root = ($this->id === static::$root);

        $this->parents = array();
        foreach ($parents as $parent)
        {
            if (is_object($parent) && get_class($parent) == $ownclass)
                $this->parents[$parent->id] = $parent;
            elseif (is_scalar($parent))
                $this->parents[$parent] = null;
            else
                throw new Exception("Parent-ID must be a " . $ownclass . " object or a scalar");
        }

        if (empty($this->parents) && !$is_root)
            $this->parents = [$this->getRoot()];

        return $this;
    }
public function setParents ( array $ parents ) { $ ownclass = get_class ( $ this ) ; $ is_root = ( $ this -> id === static :: $ root ) ; $ this -> parents = array ( ) ; foreach ( $ parents as $ parent ) { if ( is_object ( $ parent ) && get_class ( $ parent ) == $ ownclass ) $ this -> parents [ $ parent -> id ] = $ parent ; elseif ( is_scalar ( $ parent ) ) $ this -> parents [ $ parent ] = null ; else throw new Exception ( "Parent-ID must be a " . $ ownclass . " object or a scalar" ) ; } if ( empty ( $ this -> parents ) && ! $ is_root ) $ this -> parents = [ $ this -> getRoot ( ) ] ; return $ this ; }
Set the parent or parents of this element

@param $parents array One or more parent elements. The values can be instances of the same
class or scalars referring to these instances.
@Return $this Provides fluent interface
@throws Wedeto\ACL\Exception When invalid types of parents are specified
Set the parent or parents of this element