<?php
namespace App\Controller\Web;
use App\Entity\InternalEvent;
use App\Entity\MainEvent;
use App\Entity\User;
use App\Processor\MainEventProcessor;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class MainEventController
* @package App\Controller\Web
*
* @Route("/admin/event", name="admin_main_event")
*/
class MainEventController extends AbstractController
{
private $mainEventProcessor;
public function __construct(
MainEventProcessor $mainEventProcessor
) {
$this->mainEventProcessor = $mainEventProcessor;
}
/**
* @Route("", name="_listing")
*/
public function index()
{
$mainEventList = $this->getDoctrine()->getRepository(MainEvent::class)
->findBy([], [
'startDate' => 'DESC'
]);
return $this->render('admin/main-event-listing.html.twig', [
'mainEventList' => $mainEventList,
'wlpgaDomain' => $_SERVER['WLPGA_DOMAIN'],
]);
}
/**
* @Route("/{mainEventId}/registration/summary", name="_registration_summary")
*
* @ParamConverter("mainEvent", options={"mapping": {"mainEventId" : "id"}})
*/
public function registrationSummary(Request $request, MainEvent $mainEvent)
{
/** @var User $user */
$user = $this->getUser();
return $this->render('admin/internal-event-details-attendee-summary.html.twig', [
'mainEvent' => $mainEvent,
'attendees' => $this->mainEventProcessor->extractMainEventAttendeesByRegistrant($mainEvent, $user->getPerson())
]);
}
/**
* Decline attendance to this main event in behalf of the user's whole organization.
*
* @Route("/{mainEventId}/decline", name="_decline")
*
* @ParamConverter("mainEvent", options={"mapping": {"mainEventId" : "id"}})
*/
public function decline(Request $request, MainEvent $mainEvent)
{
/** @var User $user */
$user = $this->getUser();
if ($request->getMethod() == 'POST') {
$this->mainEventProcessor->processRefusal($mainEvent, $request, $user->getPerson());
$this->addFlash("success", "You have declined attendance to " . $mainEvent->getTitle());
}
return $this->redirectToRoute("admin_internal_event_listing", [
"mainEventId" => $mainEvent->getId()
]);
}
}