src/Controller/Web/MainEventController.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Web;
  3. use App\Entity\InternalEvent;
  4. use App\Entity\MainEvent;
  5. use App\Entity\User;
  6. use App\Processor\MainEventProcessor;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. /**
  12.  * Class MainEventController
  13.  * @package App\Controller\Web
  14.  *
  15.  * @Route("/admin/event", name="admin_main_event")
  16.  */
  17. class MainEventController extends AbstractController
  18. {
  19.     private $mainEventProcessor;
  20.     public function __construct(
  21.         MainEventProcessor $mainEventProcessor
  22.     ) {
  23.         $this->mainEventProcessor $mainEventProcessor;
  24.     }
  25.     /**
  26.      * @Route("", name="_listing")
  27.      */
  28.     public function index()
  29.     {
  30.         $mainEventList $this->getDoctrine()->getRepository(MainEvent::class)
  31.             ->findBy([], [
  32.                 'startDate' => 'DESC'
  33.             ]);
  34.         return $this->render('admin/main-event-listing.html.twig', [
  35.             'mainEventList' => $mainEventList,
  36.             'wlpgaDomain' => $_SERVER['WLPGA_DOMAIN'],
  37.         ]);
  38.     }
  39.     /**
  40.      * @Route("/{mainEventId}/registration/summary", name="_registration_summary")
  41.      *
  42.      * @ParamConverter("mainEvent", options={"mapping": {"mainEventId" : "id"}})
  43.      */
  44.     public function registrationSummary(Request $requestMainEvent $mainEvent)
  45.     {
  46.         /** @var User $user */
  47.         $user $this->getUser();
  48.         return $this->render('admin/internal-event-details-attendee-summary.html.twig', [
  49.             'mainEvent' => $mainEvent,
  50.             'attendees' => $this->mainEventProcessor->extractMainEventAttendeesByRegistrant($mainEvent$user->getPerson())
  51.         ]);
  52.     }
  53.     /**
  54.      * Decline attendance to this main event in behalf of the user's whole organization.
  55.      *
  56.      * @Route("/{mainEventId}/decline", name="_decline")
  57.      *
  58.      * @ParamConverter("mainEvent", options={"mapping": {"mainEventId" : "id"}})
  59.      */
  60.     public function decline(Request $requestMainEvent $mainEvent)
  61.     {
  62.         /** @var User $user */
  63.         $user $this->getUser();
  64.         if ($request->getMethod() == 'POST') {
  65.             $this->mainEventProcessor->processRefusal($mainEvent$request$user->getPerson());
  66.             $this->addFlash("success""You have declined attendance to " $mainEvent->getTitle());
  67.         }
  68.         return $this->redirectToRoute("admin_internal_event_listing", [
  69.             "mainEventId" => $mainEvent->getId()
  70.         ]);
  71.     }
  72. }