本文整理汇总了PHP中humhub\modules\user\models\User::afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP User::afterSave方法的具体用法?PHP User::afterSave怎么用?PHP User::afterSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类humhub\modules\user\models\User
的用法示例。
在下文中一共展示了User::afterSave方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterSave
/**
* Aligns the given group selection with the db
* @return boolean
*/
public function afterSave($insert, $changedAttributes)
{
//Check old group selection and remove non selected groups
foreach ($this->currentGroups as $userGroup) {
if (!$this->isInGroupSelection($userGroup)) {
$this->getGroupUsers()->where(['group_id' => $userGroup->id])->one()->delete();
}
}
$this->groupSelection = $this->groupSelection == null ? [] : $this->groupSelection;
//Add all new selectedGroups to the given user
foreach ($this->groupSelection as $groupId) {
if (!$this->isCurrentlyMemberOf($groupId)) {
Group::findOne($groupId)->addUser($this);
}
}
return parent::afterSave($insert, $changedAttributes);
}