public function testAddToTeam()
 {
     /** @var User $user */
     $user = $this->getMock('AppBundle\\Entity\\User');
     /** @var Team $team */
     $team = $this->getMock('AppBundle\\Entity\\Team');
     $teamMember = TeamMember::addToTeam($user, $team, 'Developer');
     $this->assertInstanceOf('AppBundle\\Entity\\TeamMember', $teamMember);
     $this->assertEquals('Developer', $teamMember->getPosition());
 }
 /**
  * @Route("/", name="answer")
  * @Method({"GET", "POST"})
  */
 public function indexAction(Request $request)
 {
     /**
      * get all questionnaires for the user
      * then list them
      */
     $em = $this->getDoctrine()->getManager();
     $inviteForm = $this->createFormBuilder()->add('id', 'text', array('label' => 'Team id'))->add('save', 'submit', array('label' => 'Submit'))->getForm();
     $inviteForm->handleRequest($request);
     if ($inviteForm->isSubmitted() && $inviteForm->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $team = $em->getRepository('AppBundle:Team')->find($inviteForm["id"]->getData());
         if (!$team) {
             $this->get('session')->getFlashBag()->add('danger', 'No team found!');
             return $this->redirectToRoute('answer');
         }
         $membership = new TeamMember();
         $membership->setUser($this->getUser());
         $membership->setTeam($team);
         $membership->setRole("user");
         $em->persist($membership);
         $this->getUser()->addTeam($membership);
         $team->addMember($membership);
         $em->flush();
         $this->get('session')->getFlashBag()->add('notice', 'Joined new team succesfully!');
     }
     $userTeams = $this->getUser()->getTeams();
     $questionnaires = array();
     foreach ($userTeams as $membership) {
         foreach ($membership->getTeam()->getProjects() as $project) {
             if ($project->getQuestionnaire() != null) {
                 foreach ($project->getQuestionnaire() as $q) {
                     if (!in_array($q, $questionnaires)) {
                         $questionnaires[] = $q;
                     }
                 }
             }
         }
     }
     return $this->render('Questionnaire/Answer/answer.html.twig', array('questionnaires' => $questionnaires, 'inviteForm' => $inviteForm->createView()));
 }
Example #3
0
 public function load(ObjectManager $manager)
 {
     $service = new Service();
     $service->setName('E-Commerce');
     $service->setDescription('Listos para comerciar. Publicidad acerca de seguridad. Lorem ipsun pruebas, texto aleatorio y sin sentido.');
     $service->setIcon('shopping-cart');
     $manager->persist($service);
     $service = new Service();
     $service->setName('Web Design');
     $service->setDescription('Detalles referente al diseño web. Publicidad acerca de seguridad. Lorem ipsun pruebas, texto aleatorio y sin sentido.');
     $service->setIcon('laptop');
     $manager->persist($service);
     $service = new Service();
     $service->setName('Seguridad');
     $service->setDescription('Publicidad acerca de seguridad. Lorem ipsun pruebas, texto aleatorio y sin sentido.');
     $service->setIcon('lock');
     $manager->persist($service);
     $serviceSection = new ServiceSection();
     $serviceSection->setName('Servicios');
     $serviceSection->setTextDescription('Una descripción de nuestros servicios. Puede ser más de una línea');
     $manager->persist($serviceSection);
     $homeSection = new HomeSection();
     $homeSection->setPageName('CodeXAvant Studio');
     $homeSection->setFirstHeader('Una buena experiencia');
     $homeSection->setSecondHeader('Un excelente recuerdo');
     $homeSection->setButtonLabel('Conozca más');
     $homeSection->setCopyRight('Copyright © Your Website 2014');
     $manager->persist($homeSection);
     $teamSection = new TeamSection();
     $teamSection->setTeamHeader('Conozca Nuestro Equipo');
     $teamSection->setDescription('Nuestro equipo está compuesto por un versátil grupo');
     $manager->persist($teamSection);
     $teamMember = new TeamMember();
     $teamMember->setName('DaVinci OneWay');
     $teamMember->setPosition('Diseñador');
     $teamMember->setImage('highway_nights-100x100.jpg');
     $teamMember->setUpdatedAt(new \DateTime());
     $manager->persist($teamMember);
     $teamMember = new TeamMember();
     $teamMember->setName('King Athur');
     $teamMember->setPosition('CEO');
     $teamMember->setImage('wall_bsod-200x200.jpg');
     $teamMember->setUpdatedAt(new \DateTime());
     $manager->persist($teamMember);
     $teamMember = new TeamMember();
     $teamMember->setName('Philip ByteCode');
     $teamMember->setPosition('Programador');
     $teamMember->setImage('LitleH-100.jpg');
     $teamMember->setUpdatedAt(new \DateTime());
     $manager->persist($teamMember);
     $manager->flush();
 }
Example #4
0
 /**
  * @Route("/team/removemember/{id}", name="removemember",
  * requirements = { "id" = "\d+" },
  * methods = { "GET", "POST" })
  *
  */
 public function memberRemoveAction(Request $request, TeamMember $member)
 {
     $em = $this->getDoctrine()->getManager();
     $team = $member->getTeam();
     $team->removeMember($member);
     $user = $member->getUser();
     $user->removeTeam($member);
     $em->remove($member);
     $em->flush();
     $this->get('session')->getFlashBag()->add('notice', 'User was removed succesfully!');
     return $this->redirectToRoute('team_edit', array('id' => $team->getId()));
 }