/** * Pass an ARRAY of Role objects and will clear the collection and re-set it with new Roles. * Type hinted array due to interface. * * @param array $roles Of Role objects. */ public function setRoles(array $roles) { $this->user_roles->clear(); $parentRoles = array(); foreach ($roles as $role) { $this->addRole($role); $parentRoles[] = $role->getName(); } parent::setRoles($parentRoles); }