/** * Add a user group to this collection. * * @param GroupInterface $group The user group to add * * @return GroupCollection Returns $this for chainability * * @throws \InvalidArgumentException If a group with the same name has * already been set on this collection */ public function add(GroupInterface $group) { if (isset($this->_groups[$group->getName()])) { throw new \InvalidArgumentException(sprintf('User group `%s` is already defined', $group->getName())); } $this->_groups[$group->getName()] = $group; return $this; }
/** * Returns all users who belong to * a group. * * @param GroupInterface $group * * @return array */ public function findAllInGroup(GroupInterface $group) { return $group->users()->get(); }
/** * Save a group. * @param \vakata\user\GroupInterface $group the group to save * @return self */ public function saveGroup(GroupInterface $group) : UserManagementInterface { if (!isset($this->groups[$group->getID()])) { $this->groups[$group->getID()] = $group; } $this->permissions = array_values(array_unique(array_merge($this->permissions, $group->getPermissions()))); return $this; }
public function add(GroupInterface $group) { $this->groups[$group->getName()] = $group; }