public function beforeSave($insert) { if (parent::beforeSave($insert)) { $ruleClass = "backend\\modules\\rbac\\rules\\{$this->data}"; $this->data = serialize(new $ruleClass()); return true; } else { return false; } }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->type == 1) { Yii::$app->cache->delete(self::tableName() . 'getRoles'); } if ($this->rule_name === '') { $this->rule_name = null; } /** * надо сериализовать данные для правила */ if ($this->data) { $this->data = serialize($this->data); } return true; } else { return false; } }
/** * @param bool $insert * @return bool * @throws Exception * @throws \yii\base\InvalidConfigException */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->isNewRecord) { $this->auth_key = Yii::$app->getSecurity()->generateRandomString(); } if ($this->password) { $this->password_hash = Yii::$app->getSecurity()->generatePasswordHash($this->password); } return true; } else { return false; } }