コード例 #1
0
ファイル: User.php プロジェクト: xamin123/platform
 /**
  * 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;
 }
コード例 #2
0
ファイル: User.php プロジェクト: blitzik/CMS
 public function clearRoles()
 {
     $this->roles->clear();
 }