Ejemplo n.º 1
0
 /**
  * Pass an array or Collection of Role objects and re-set roles collection with new Roles.
  * Type hinted array due to interface.
  *
  * @param  array|Collection $roles Array of Role objects
  *
  * @return User
  * @throws \InvalidArgumentException
  */
 public function setRoles($roles)
 {
     if (!$roles instanceof Collection && !is_array($roles)) {
         throw new \InvalidArgumentException('$roles must be an instance of Doctrine\\Common\\Collections\\Collection or an array');
     }
     $this->roles->clear();
     foreach ($roles as $role) {
         $this->addRole($role);
     }
     return $this;
 }
Ejemplo n.º 2
0
Archivo: User.php Proyecto: blitzik/CMS
 public function clearRoles()
 {
     $this->roles->clear();
 }