<commit_before><?php
namespace AppBundle\Controller\Event;


use AppBundle\Entity\Event;
use AppBundle\Form\EventAcquisitionType;
use AppBundle\Form\EventMailType;
use AppBundle\Form\EventType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;


class AdminController extends Controller
{

    /**
     * Page for list of events
     *
     * @Route("/admin/event/list", name="event_list")
     * @Security("has_role('ROLE_ADMIN_EVENT')")
     */
    public function listAction()
    {
        $repository      = $this->getDoctrine()
                                ->getRepository('AppBundle:Event');
        $eventListFuture = $repository->findEidListFutureEvents();
        $eventListPast   = $repository->findEidListPastEvents();

        return $this->render(
            'event/admin/list.html.twig',
            array(
                'eventListFuture' => $eventListFuture,
                'eventListPast'   => $eventListPast,
                'eventList'       => array_merge($eventListFuture, $eventListPast)
            )
        );
    }

    /**
     * Data provider for event list grid
     *
     * @Route("/admin/event/list.json", name="event_list_data")
     * @Security("has_role('ROLE_ADMIN_EVENT')")
     */
    public function listDataAction(Request $request)
    {
        $repository      = $this->getDoctrine()
                                ->getRepository('AppBundle:Event');
        $eventEntityList = $repository->findAll();

        $dateFormatDay     = 'd.m.y';
        $dateFormatDayHour = 'd.m.y H:i';
        $glyphicon         = '<span class="glyphicon glyphicon-%s" aria-hidden="true"></span> ';

        $eventList = array();
        /** @var Event $event */
        foreach ($eventEntityList as $event) {
            $eventStatus = '';
            if ($event->isVisible()) {
                $eventStatus .= sprintf($glyphicon, 'eye-open');
            } else {
                $eventStatus .= sprintf($glyphicon, 'eye-close');
            }

            if ($event->isActive()) {
                $eventStatus .= sprintf($glyphicon, 'folder-open');
            } else {
                $eventStatus .= sprintf($glyphicon, 'folder-close');
            }

            $eventStartFormat = $dateFormatDayHour;
            if ($event->getStartDate()
                      ->format('Hi') == '0000'
            ) {
                $eventStartFormat = $dateFormatDay;
            }
            $eventEndFormat = $dateFormatDayHour;
            if ($event->getEndDate()
                      ->format('Hi') == '0000'
            ) {
                $eventEndFormat = $dateFormatDay;
            }

            $eventList[] = array(
                'eid'         => $event->getEid(),
                'is_visible'  => (int)$event->isVisible(),
                'is_active'   => (int)$event->isActive(),
                'title'       => $event->getTitle(),
                'description' => $event->getTitle(),
                'start_date'  => $event->getStartDate()
                                       ->format($eventStartFormat),
                'end_date'    => $event->getEndDate()
                                       ->format($eventEndFormat),
                'status'      => $eventStatus
            );
        }


        return new JsonResponse($eventList);
    }

    /**
     * Edit page for one single event
     *
     * @Route("/admin/event/{eid}/edit", requirements={"eid": "\d+"}, name="event_edit")
     * @Security("has_role('ROLE_ADMIN_EVENT')")
     */
    public function editAction(Request $request)
    {
        $eid = $request->get('eid');

        $repository = $this->getDoctrine()
                           ->getRepository('AppBundle:Event');

        $event = $repository->findOneBy(array('eid' => $eid));
        if (!$event) {
            return $this->render(
                'event/public/miss.html.twig', array('eid' => $eid),
                new Response(null, Response::HTTP_NOT_FOUND)
            );
        }

        $form = $this->createForm(EventType::class, $event);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()
                       ->getManager();

            $em->persist($event);
            $em->flush();

            return $this->redirect('/event/' . $event->getEid());
        }

        return $this->render(
            'event/admin/edit.html.twig', array(
                                            'event' => $event,
                                            'form'  => $form->createView(),
                                        )
        );<commit_msg>Now redirecting to admin event page after save edit<commit_after><?php
namespace AppBundle\Controller\Event;


use AppBundle\Entity\Event;
use AppBundle\Form\EventAcquisitionType;
use AppBundle\Form\EventMailType;
use AppBundle\Form\EventType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;


class AdminController extends Controller
{

    /**
     * Page for list of events
     *
     * @Route("/admin/event/list", name="event_list")
     * @Security("has_role('ROLE_ADMIN_EVENT')")
     */
    public function listAction()
    {
        $repository      = $this->getDoctrine()
                                ->getRepository('AppBundle:Event');
        $eventListFuture = $repository->findEidListFutureEvents();
        $eventListPast   = $repository->findEidListPastEvents();

        return $this->render(
            'event/admin/list.html.twig',
            array(
                'eventListFuture' => $eventListFuture,
                'eventListPast'   => $eventListPast,
                'eventList'       => array_merge($eventListFuture, $eventListPast)
            )
        );
    }

    /**
     * Data provider for event list grid
     *
     * @Route("/admin/event/list.json", name="event_list_data")
     * @Security("has_role('ROLE_ADMIN_EVENT')")
     */
    public function listDataAction(Request $request)
    {
        $repository      = $this->getDoctrine()
                                ->getRepository('AppBundle:Event');
        $eventEntityList = $repository->findAll();

        $dateFormatDay     = 'd.m.y';
        $dateFormatDayHour = 'd.m.y H:i';
        $glyphicon         = '<span class="glyphicon glyphicon-%s" aria-hidden="true"></span> ';

        $eventList = array();
        /** @var Event $event */
        foreach ($eventEntityList as $event) {
            $eventStatus = '';
            if ($event->isVisible()) {
                $eventStatus .= sprintf($glyphicon, 'eye-open');
            } else {
                $eventStatus .= sprintf($glyphicon, 'eye-close');
            }

            if ($event->isActive()) {
                $eventStatus .= sprintf($glyphicon, 'folder-open');
            } else {
                $eventStatus .= sprintf($glyphicon, 'folder-close');
            }

            $eventStartFormat = $dateFormatDayHour;
            if ($event->getStartDate()
                      ->format('Hi') == '0000'
            ) {
                $eventStartFormat = $dateFormatDay;
            }
            $eventEndFormat = $dateFormatDayHour;
            if ($event->getEndDate()
                      ->format('Hi') == '0000'
            ) {
                $eventEndFormat = $dateFormatDay;
            }

            $eventList[] = array(
                'eid'         => $event->getEid(),
                'is_visible'  => (int)$event->isVisible(),
                'is_active'   => (int)$event->isActive(),
                'title'       => $event->getTitle(),
                'description' => $event->getTitle(),
                'start_date'  => $event->getStartDate()
                                       ->format($eventStartFormat),
                'end_date'    => $event->getEndDate()
                                       ->format($eventEndFormat),
                'status'      => $eventStatus
            );
        }


        return new JsonResponse($eventList);
    }

    /**
     * Edit page for one single event
     *
     * @Route("/admin/event/{eid}/edit", requirements={"eid": "\d+"}, name="event_edit")
     * @Security("has_role('ROLE_ADMIN_EVENT')")
     */
    public function editAction(Request $request)
    {
        $eid = $request->get('eid');

        $repository = $this->getDoctrine()
                           ->getRepository('AppBundle:Event');

        $event = $repository->findOneBy(array('eid' => $eid));
        if (!$event) {
            return $this->render(
                'event/public/miss.html.twig', array('eid' => $eid),
                new Response(null, Response::HTTP_NOT_FOUND)
            );
        }

        $form = $this->createForm(EventType::class, $event);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()
                       ->getManager();

            $em->persist($event);
            $em->flush();

            return $this->redirectToRoute('event', array('eid' => $event->getEid()));
        }

        return $this->render(
            'event/admin/edit.html.twig', array(
                                            'event' => $event,
                                            'form'  => $form->createView(),
                                        )
        );
{'fraction_non_alphanumeric': 0.1435753066559421, 'fraction_numerical': 0.0016086869093102755, 'mean_word_length': 1.712571584401418, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 116, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6534862', 'n_tokens_mistral': 2765, 'n_tokens_neox': 2648, 'n_words': 425}