示例#1
0
 /**
  * @param UserInterface $user
  * @param int[]         $ids
  *
  * @return UserInterface
  */
 private function setGroups(UserInterface $user, $ids)
 {
     $gRepository = $this->entityManager->getRepository('BDNUserBundle:Group');
     $groups = $gRepository->findAll();
     foreach ($ids as $id) {
         foreach ($groups as $group) {
             if ($group->getCommunityId() == $id) {
                 $user->addGroup($group);
                 break;
             }
         }
     }
     return $user;
 }