/** * @inheritdoc */ public function add($object) { if ($object instanceof Item) { //①如果是role或permission对象就创建auth_rule if ($object->ruleName && $this->getRule($object->ruleName) === null) { //如果规则是空的 就创建规则 $rule = \Yii::createObject($object->ruleName); $rule->name = $object->ruleName; $this->addRule($rule); } return $this->addItem($object); } elseif ($object instanceof Rule) { return $this->addRule($object); } else { throw new InvalidParamException(‘Adding unsupported object type.‘); } }
时间: 2024-10-12 09:52:58