Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 /**
  * Returns all users who belong to
  * a group.
  *
  * @param GroupInterface $group
  *
  * @return array
  */
 public function findAllInGroup(GroupInterface $group)
 {
     return $group->users()->get();
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 public function add(GroupInterface $group)
 {
     $this->groups[$group->getName()] = $group;
 }