/** * Supprime le membre de la team * * @param User $user * @param Team $team * * @author Benjamin Levoir <*****@*****.**> */ public function removeTeamMember(User $user, Team $team) { foreach ($team->getTeamUsers() as $teamUser) { if ($user == $teamUser->getUser()) { $this->em->remove($teamUser); } } $this->em->flush(); }
/** * Fonction de modification d'une équipe * * @param integer $id * @return Response * * @Template() * @Route("/add", name="team_add") * @Route("/edit/{id}", name="team_edit") * @Method({"GET", "POST"}) * * @Security("has_role('ROLE_USER')") * @author Benjamin Levoir <*****@*****.**> */ public function editTeamAction(Request $request, $id = null) { if ($request->get('_route') == 'team_add') { $team = new Team(); $team->setCaptain($this->getUser()); } else { $team = $this->getTeam($id, true); } $form = $this->createForm(new \CoreBundle\Form\TeamType(), $team, array('edit' => $request->get('_route') == 'team_edit', 'servers' => $this->getParameter('servers'))); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->get('core.team')->saveTeam($team, $request->get('_route') == 'team_add'); $this->addFlash('success', 'lg.flash.success.team.saved'); return $this->redirect($this->generateUrl('team_infos', array('id' => $team->getId()))); } return array('edit' => $request->get('_route') == 'team_edit', 'team' => $team, 'form' => $form->createView()); }
/** * Init le tableau de compo de team * * @param Team $team * @return array * @author Benjamin Levoir <*****@*****.**> */ private function initTeamCompTable(\CoreBundle\Entity\Team $team) { $table = array(); $levelTable = array(UserChampion::LEVEL_MAIN => array(), UserChampion::LEVEL_PLAYED => array(), UserChampion::LEVEL_TRAIN => array()); $players = $this->em->getRepository('CoreBundle:TeamUser')->getPlayersInTeam($team->getId()); foreach ($players as $player) { $table[$player['id']] = array('name' => empty($player['displayName']) ? $player['username'] : $player['displayName'], 'role' => $player['role'], 'data' => $levelTable); } return $table; }
/** * Récupère tous les calendriers des membres officiels de la team * * @param Team $team * @return array * * @author Benjamin Levoir <*****@*****.**> */ public function getTeamMembersCalendars(Team $team) { $data = $this->em->getRepository('CoreBundle:UserCalendar')->getLastMessage($team->getId()); return $data; }