framework/rbac/DbManager.php
public function addChild($parent, $child)
    {
        if ($parent->name === $child->name) {
            throw new InvalidArgumentException("Cannot add '{$parent->name}' as a child of itself.");
        }

        if ($parent instanceof Permission && $child instanceof Role) {
            throw new InvalidArgumentException('Cannot add a role as a child of a permission.');
        }

        if ($this->detectLoop($parent, $child)) {
            throw new InvalidCallException("Cannot add '{$child->name}' as a child of '{$parent->name}'. A loop has been detected.");
        }

        $this->db->createCommand()
            ->insert($this->itemChildTable, ['parent' => $parent->name, 'child' => $child->name])
            ->execute();

        $this->invalidateCache();

        return true;
    }
public function addChild($parent, $child)
    {
        if ($parent->name === $child->name) {
            throw new InvalidArgumentException("Cannot add '{$parent->name}' as a child of itself.");
        }

        if ($parent instanceof Permission && $child instanceof Role) {
            throw new InvalidArgumentException('Cannot add a role as a child of a permission.');
        }

        if ($this->detectLoop($parent, $child)) {
            throw new InvalidCallException("Cannot add '{$child->name}' as a child of '{$parent->name}'. A loop has been detected.");
        }

        $this->db->createCommand()
            ->insert($this->itemChildTable, ['parent' => $parent->name, 'child' => $child->name])
            ->execute();

        $this->invalidateCache();

        return true;
    }
public function addChild ( $ parent , $ child ) { if ( $ parent -> name === $ child -> name ) { throw new InvalidArgumentException ( "Cannot add '{$parent->name}' as a child of itself." ) ; } if ( $ parent instanceof Permission && $ child instanceof Role ) { throw new InvalidArgumentException ( 'Cannot add a role as a child of a permission.' ) ; } if ( $ this -> detectLoop ( $ parent , $ child ) ) { throw new InvalidCallException ( "Cannot add '{$child->name}' as a child of '{$parent->name}'. A loop has been detected." ) ; } $ this -> db -> createCommand ( ) -> insert ( $ this -> itemChildTable , [ 'parent' => $ parent -> name , 'child' => $ child -> name ] ) -> execute ( ) ; $ this -> invalidateCache ( ) ; return true ; }
{@inheritdoc}
{