public function _cmsAfterSave($e)
{
if ($this->_roleNames !== null) {
if ($this->roles) {
foreach ($this->roles as $roleExist) {
if (!in_array($roleExist->name, (array) $this->_roleNames)) {
\Yii::$app->authManager->revoke($roleExist, $this->id);
}
}
}
foreach ((array) $this->_roleNames as $roleName) {
if ($role = \Yii::$app->authManager->getRole($roleName)) {
try {
\Yii::$app->authManager->assign($role, $this->id);
} catch (\Exception $e) {
}
}
}
}
}