yii\rbac\DbManager::removeAllItems PHP Метод

removeAllItems() защищенный Метод

Removes all auth items of the specified type.
protected removeAllItems ( integer $type )
$type integer the auth item type (either Item::TYPE_PERMISSION or Item::TYPE_ROLE)
    protected function removeAllItems($type)
    {
        if (!$this->supportsCascadeUpdate()) {
            $names = (new Query())->select(['name'])->from($this->itemTable)->where(['type' => $type])->column($this->db);
            if (empty($names)) {
                return;
            }
            $key = $type == Item::TYPE_PERMISSION ? 'child' : 'parent';
            $this->db->createCommand()->delete($this->itemChildTable, [$key => $names])->execute();
            $this->db->createCommand()->delete($this->assignmentTable, ['item_name' => $names])->execute();
        }
        $this->db->createCommand()->delete($this->itemTable, ['type' => $type])->execute();
        $this->invalidateCache();
    }

Usage Example

Пример #1
0
 /**
  * @inheritdoc
  */
 protected function removeAllItems($type)
 {
     parent::removeAllItems($type);
     $this->_assignments = [];
     $this->_children = $this->_items = null;
     $this->invalidate([self::PART_ITEMS, self::PART_CHILDREN]);
 }