FOS\UserBundle\Model\UserInterface::addGroup PHP Method

addGroup() public method

public addGroup ( FOS\UserBundle\Model\GroupInterface $group )
$group FOS\UserBundle\Model\GroupInterface
    function addGroup(GroupInterface $group);

Usage Example

 protected function onSuccess(UserInterface $user, $confirmation)
 {
     // Note: if you plan on modifying the user then do it before calling the
     // parent method as the parent method will flush the changes
     /* @var $user \Projet0\Homepage\LoginBundle\Entity\User */
     $group = $this->container->get('doctrine')->getEntityManager()->getRepository('Projet0HomepageLoginBundle:Group')->findOneByName($this->defaultGroup);
     if ($group) {
         $user->addGroup($group);
     }
     parent::onSuccess($user, $confirmation);
     // otherwise add your functionality here
 }