/**
  * @Route("/manage/{listUrl}", name="pool_manage")
  * @Template()
  */
 public function manageAction(Request $request, $listUrl)
 {
     $this->getPool($listUrl);
     if (!$this->pool->getCreated()) {
         return $this->redirect($this->generateUrl('pool_exclude', ['listUrl' => $this->pool->getListurl()]));
     }
     if ($this->pool->getSentdate() === null) {
         $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('flashes.manage.email_validated'));
         $this->get('intracto_secret_santa.mail')->sendSecretSantaMailsForPool($this->pool);
     }
     $eventDate = date_format($this->pool->getEventdate(), 'Y-m-d');
     $oneWeekFromEventDate = date('Y-m-d', strtotime($eventDate . '- 1 week'));
     $newEntry = new Entry();
     $updatePool = $this->pool;
     $addEntryForm = $this->createForm(AddEntryType::class, $newEntry);
     $updatePoolDetailsForm = $this->createForm(UpdatePoolDetailsType::class, $updatePool);
     if ($request->getMethod('POST')) {
         $addEntryForm->handleRequest($request);
         $updatePoolDetailsForm->handleRequest($request);
         if ($addEntryForm->isSubmitted()) {
             if ($addEntryForm->isValid()) {
                 if (date('Y-m-d') > $oneWeekFromEventDate) {
                     $this->get('session')->getFlashBag()->add('warning', $this->get('translator')->trans('flashes.modify_list.warning'));
                     return $this->redirect($this->generateUrl('pool_manage', ['listUrl' => $listUrl]));
                 }
                 $newEntry->setUrl(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36));
                 $newEntry->setPool($this->pool);
                 $this->get('doctrine.orm.entity_manager')->persist($newEntry);
                 $this->get('doctrine.orm.entity_manager')->flush($newEntry);
                 $adminId = $this->get('intracto_secret_santa.entry')->findAdminIdByPoolId($this->pool->getId());
                 $admin = $this->get('entry_repository')->findOneById($adminId[0]['id']);
                 $adminMatch = $admin->getEntry();
                 $admin->setEntry($newEntry);
                 $this->get('doctrine.orm.entity_manager')->persist($admin);
                 $this->get('doctrine.orm.entity_manager')->flush($admin);
                 $newEntry->setEntry($adminMatch);
                 $this->get('doctrine.orm.entity_manager')->persist($newEntry);
                 $this->get('doctrine.orm.entity_manager')->flush();
                 $this->get('intracto_secret_santa.mail')->sendSecretSantaMailForEntry($newEntry);
                 $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('flashes.add_participant.success'));
                 return $this->redirect($this->generateUrl('pool_manage', ['listUrl' => $listUrl]));
             } else {
                 $this->get('session')->getFlashBag()->add('danger', $this->get('translator')->trans('flashes.add_participant.danger'));
             }
         }
         if ($updatePoolDetailsForm->isSubmitted()) {
             if ($updatePoolDetailsForm->isValid()) {
                 $time_now = new \DateTime();
                 $updatePool->setDetailsUpdated(true);
                 $updatePool->setDetailsUpdatedTime($time_now);
                 $this->get('doctrine.orm.entity_manager')->persist($updatePool);
                 $this->get('doctrine.orm.entity_manager')->flush();
                 $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('flashes.updated_party.success'));
                 return $this->redirect($this->generateUrl('pool_manage', ['listUrl' => $listUrl]));
             } else {
                 $this->get('session')->getFlashBag()->add('danger', $this->get('translator')->trans('flashes.updated_party.danger'));
             }
         }
     }
     return ['addEntryForm' => $addEntryForm->createView(), 'updatePoolDetailsForm' => $updatePoolDetailsForm->createView(), 'pool' => $this->pool, 'oneWeekFromEventDate' => $oneWeekFromEventDate, 'delete_pool_csrf_token' => $this->get('security.csrf.token_manager')->getToken('delete_pool'), 'expose_pool_csrf_token' => $this->get('security.csrf.token_manager')->getToken('expose_pool'), 'expose_pool_wishlists_csrf_token' => $this->get('security.csrf.token_manager')->getToken('expose_wishlists'), 'delete_participant_csrf_token' => $this->get('security.csrf.token_manager')->getToken('delete_participant')];
 }