Newscoop\Entity\User::removeAttribute PHP Method

removeAttribute() public method

Remove attribute
public removeAttribute ( string $name ) : Newscoop\Entity\UserAttribute
$name string
return Newscoop\Entity\UserAttribute
    public function removeAttribute($name)
    {
        return $this->attributes->remove($name);
    }

Usage Example

 /**
  * Remove user attributes
  *
  * @param Newscoop\Entity\User $user
  * @param array $attributes
  *
  * @return void
  */
 public function removeAttributes(User $user, array $attributes)
 {
     foreach ($attributes as $attribute) {
         if ($entity = $user->removeAttribute($attribute)) {
             $this->em->remove($entity);
         }
     }
     $this->em->flush();
 }