public function save()
{
if ($this->validate() == false) {
return false;
}
if ($isNewItem = $this->item === null) {
$this->item = $this->createItem($this->name);
} else {
$oldName = $this->item->name;
}
$this->item->name = $this->name;
$this->item->description = $this->description;
$this->item->data = $this->data == null ? null : Json::decode($this->data);
$this->item->ruleName = empty($this->rule) ? null : $this->rule;
if ($isNewItem) {
\Yii::$app->session->setFlash('success', \Yii::t('rbac', 'Item has been created'));
$this->manager->add($this->item);
} else {
\Yii::$app->session->setFlash('success', \Yii::t('rbac', 'Item has been updated'));
$this->manager->update($oldName, $this->item);
}
$this->updateChildren();
$this->manager->invalidateCache();
return true;
}