<commit_before><?php
/**
 * This file is part of the Juvem package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AppBundle\Controller\Event\Participation;

use AppBundle\Controller\Event\WaitingListFlashTrait;
use AppBundle\Entity\Event;
use AppBundle\Entity\NewsletterSubscription;
use AppBundle\Entity\Participation;
use AppBundle\Form\ParticipationType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

class PublicParticipateController extends Controller
{
    use WaitingListFlashTrait;

    /**
     * Page for list of events
     *
     * @ParamConverter("event", class="AppBundle:Event", options={"id" = "eid"})
     * @Route("/event/{eid}/participate", requirements={"eid": "\d+"}, name="event_public_participate")
     */
    public function participateAction(Event $event, Request $request)
    {
        $eid = $event->getEid();

        if (!$event->isActive()) {
            $this->addFlash(
                'danger',
                'Bei der gewählte Veranstaltung werden im Moment keine Anmeldungen erfasst'
            );

            return $this->redirectToRoute('homepage', ['eid' => $eid]);
        }

        if ($request->getSession()->has('participation-' . $eid)) {
            /** @var Participation $participation */
            $participation = $request->getSession()
                                     ->get('participation-' . $eid);
            $sessionEvent  = $participation->getEvent();
            if ($sessionEvent->getEid() == $eid) {
                $participation->setEvent($event); //TODO improve solution
            } else {
                return $this->render(
                    'event/public/miss.html.twig', ['eid' => $eid],
                    new Response(null, Response::HTTP_NOT_FOUND)<commit_msg>Now displaying error message including event title, no longer transmitting event id when redirecting<commit_after><?php
/**
 * This file is part of the Juvem package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AppBundle\Controller\Event\Participation;

use AppBundle\Controller\Event\WaitingListFlashTrait;
use AppBundle\Entity\Event;
use AppBundle\Entity\NewsletterSubscription;
use AppBundle\Entity\Participation;
use AppBundle\Form\ParticipationType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

class PublicParticipateController extends Controller
{
    use WaitingListFlashTrait;

    /**
     * Page for list of events
     *
     * @ParamConverter("event", class="AppBundle:Event", options={"id" = "eid"})
     * @Route("/event/{eid}/participate", requirements={"eid": "\d+"}, name="event_public_participate")
     */
    public function participateAction(Event $event, Request $request)
    {
        $eid = $event->getEid();

        if (!$event->isActive()) {
            $this->addFlash(
                'danger',
                'Für die Veranstaltung <i>' . htmlspecialchars($event->getTitle()) .
                '</i> werden im Moment keine Anmeldungen erfasst'
            );

            return $this->redirectToRoute('homepage');
        }

        if ($request->getSession()->has('participation-' . $eid)) {
            /** @var Participation $participation */
            $participation = $request->getSession()
                                     ->get('participation-' . $eid);
            $sessionEvent  = $participation->getEvent();
            if ($sessionEvent->getEid() == $eid) {
                $participation->setEvent($event); //TODO improve solution
            } else {
                return $this->render(
                    'event/public/miss.html.twig', ['eid' => $eid],
                    new Response(null, Response::HTTP_NOT_FOUND)
{'fraction_non_alphanumeric': 0.12581296254765642, 'fraction_numerical': 0.0, 'mean_word_length': 2.888404533565824, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6274867', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1201, 'n_words': 268}