Beispiel #1
0
 /**
  * @Route("/exclude/{listUrl}", name="pool_exclude")
  * @Template()
  */
 public function excludeAction(Request $request, $listUrl)
 {
     $this->getPool($listUrl);
     if ($this->pool->getCreated()) {
         $this->get('event_dispatcher')->dispatch(PoolEvents::NEW_POOL_CREATED, new PoolEvent($this->pool));
         return $this->redirect($this->generateUrl('pool_created', ['listUrl' => $this->pool->getListurl()]));
     }
     if ($this->pool->getEntries()->count() <= 3) {
         $this->pool->setCreated(true);
         $this->get('doctrine.orm.entity_manager')->persist($this->pool);
         $this->get('intracto_secret_santa.entry_service')->shuffleEntries($this->pool);
         $this->get('doctrine.orm.entity_manager')->flush();
         $this->get('event_dispatcher')->dispatch(PoolEvents::NEW_POOL_CREATED, new PoolEvent($this->pool));
         return $this->redirect($this->generateUrl('pool_created', ['listUrl' => $this->pool->getListurl()]));
     }
     $form = $this->createForm(new PoolExcludeEntryType(), $this->pool);
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $this->pool->setCreated(true);
             $this->get('doctrine.orm.entity_manager')->persist($this->pool);
             $this->get('intracto_secret_santa.entry_service')->shuffleEntries($this->pool);
             $this->get('doctrine.orm.entity_manager')->flush();
             $this->get('event_dispatcher')->dispatch(PoolEvents::NEW_POOL_CREATED, new PoolEvent($this->pool));
             return $this->redirect($this->generateUrl('pool_created', ['listUrl' => $this->pool->getListurl()]));
         }
     }
     return ['form' => $form->createView(), 'pool' => $this->pool];
 }
 /**
  * @Route("/exclude/{listUrl}", name="pool_exclude")
  * @Template()
  */
 public function excludeAction(Request $request, $listUrl)
 {
     $this->getPool($listUrl);
     if ($this->pool->getCreated()) {
         return $this->redirect($this->generateUrl('pool_created', array('listUrl' => $this->pool->getListurl())));
     }
     $form = $this->createForm(new PoolExcludeEntryType(), $this->pool);
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             $this->pool->setCreated(true);
             $em->persist($this->pool);
             $em->flush();
             $this->eventDispatcher->dispatch(PoolEvents::NEW_POOL_CREATED, new PoolEvent($this->pool));
             return $this->redirect($this->generateUrl('pool_created', array('listUrl' => $this->pool->getListurl())));
         }
     }
     return array('form' => $form->createView(), 'pool' => $this->pool);
 }
Beispiel #3
0
 /**
  * @Route("/exclude/{listUrl}", name="pool_exclude")
  * @Template()
  */
 public function excludeAction(Request $request, $listUrl)
 {
     $this->getPool($listUrl);
     if ($this->pool->getCreated()) {
         return $this->redirect($this->generateUrl('pool_created', array('listUrl' => $this->pool->getListurl())));
     }
     $form = $this->createForm(new PoolExcludeEntryType(), $this->pool);
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             $this->pool->setCreated(true);
             $em->persist($this->pool);
             /** @var \Intracto\SecretSantaBundle\Entity\EntryService $entryService */
             $entryService = $this->get('intracto_secret_santa.entry_service');
             $entryService->shuffleEntries($this->pool);
             $em->flush();
             $this->eventDispatcher->dispatch(PoolEvents::NEW_POOL_CREATED, new PoolEvent($this->pool));
             return $this->redirect($this->generateUrl('pool_created', array('listUrl' => $this->pool->getListurl())));
         }
     }
     return array('form' => $form->createView(), 'pool' => $this->pool);
 }