/** * */ public function saveItem() { try { $item = $this->type == self::TYPE_ROLE ? $this->_authMan->createRole($this->name) : $this->_authMan->createPermission($this->name); $item->name = $this->name; $item->type = $this->type; $item->description = $this->description; $item->createdAt = time(); $item->updatedAt = time(); $this->_authMan->add($item); return true; } catch (\yii\db\Exception $e) { if ($e->getCode() == 23000) { $this->addError('name', RbacModule::t('simplerbac', 'Item also exists')); } else { $this->addError('name', 'Error ' . $e->getName() . ' #' . $e->getCode()); } return false; } }