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