<commit_before><?php

namespace Hackzilla\Bundle\TicketBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Hackzilla\Bundle\TicketBundle\Entity\Ticket;
use Hackzilla\Bundle\TicketBundle\Entity\TicketMessage;
use Hackzilla\Bundle\TicketBundle\Form\TicketType;
use Hackzilla\Bundle\TicketBundle\Form\TicketMessageType;

/**
 * Ticket controller.
 *
 */
class TicketController extends Controller
{

    /**
     * Lists all Ticket entities.
     *
     */
    public function indexAction(Request $request)
    {
        $userManager = $this->get('hackzilla_ticket.user');
        $translator = $this->get('translator');

        $ticketState = $request->get('state', $translator->trans('STATUS_OPEN'));

        $repositoryTicket = $this->getDoctrine()
                ->getRepository('HackzillaTicketBundle:Ticket');

        $repositoryTicketMessage = $this->getDoctrine()
                ->getRepository('HackzillaTicketBundle:TicketMessage');

        $query = $repositoryTicket->getTicketList($userManager, $repositoryTicketMessage->getTicketStatus($translator, $ticketState));

        $paginator = $this->get('knp_paginator');
        $pagination = $paginator->paginate(
            $query->getQuery(),
            $request->query->get('page', 1)/*page number*/,
            10/*limit per page*/
        );

        return $this->render('HackzillaTicketBundle:Ticket:index.html.twig', array(
                    'pagination' => $pagination,
                    'ticketState' => $ticketState,
        ));
    }

    /**
     * Creates a new Ticket entity.
     *
     */
    public function createAction(Request $request)
    {
        $userManager = $this->get('hackzilla_ticket.user');

        $ticket = new Ticket();
        $form = $this->createForm(new TicketType($userManager), $ticket);
        $form->handleRequest($request);

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

            $message = $ticket->getMessages()->current();
            $message->setStatus(TicketMessage::STATUS_OPEN);
            $message->setUser($userManager->getCurrentUser());
            $message->setTicket($ticket);

            $em->persist($ticket);
            $em->persist($message);

            $em->flush();

            return $this->redirect($this->generateUrl('hackzilla_ticket_show', array('id' => $ticket->getId())));
        }

        return $this->render('HackzillaTicketBundle:Ticket:new.html.twig', array(
                    'entity' => $ticket,
                    'form' => $form->createView(),
        ));
    }

    /**
     * Displays a form to create a new Ticket entity.
     *
     */
    public function newAction()
    {
        $entity = new Ticket();
        $userManager = $this->get('hackzilla_ticket.user');
        $form = $this->createForm(new TicketType($userManager), $entity);

        return $this->render('HackzillaTicketBundle:Ticket:new.html.twig', array(
                    'entity' => $entity,
                    'form' => $form->createView(),
        ));
    }

    /**
     * Finds and displays a Ticket entity.
     *
     */
    public function showAction(Ticket $ticket)
    {
        $userManager = $this->get('hackzilla_ticket.user');
        $this->checkUserPermission($userManager->getCurrentUser(), $ticket);

        $data = array('ticket' => $ticket);

        $message = new TicketMessage();
        $message->setPriority($ticket->getPriority());

        if (TicketMessage::STATUS_CLOSED != $ticket->getStatus()) {
            $data['form'] = $this->createForm(new TicketMessageType($userManager), $message)->createView();
        }

        $data['delete_form'] = $this->createDeleteForm($ticket->getId())->createView();

        return $this->render('HackzillaTicketBundle:Ticket:show.html.twig', $data);<commit_msg>set default status on reply<commit_after><?php

namespace Hackzilla\Bundle\TicketBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Hackzilla\Bundle\TicketBundle\Entity\Ticket;
use Hackzilla\Bundle\TicketBundle\Entity\TicketMessage;
use Hackzilla\Bundle\TicketBundle\Form\TicketType;
use Hackzilla\Bundle\TicketBundle\Form\TicketMessageType;

/**
 * Ticket controller.
 *
 */
class TicketController extends Controller
{

    /**
     * Lists all Ticket entities.
     *
     */
    public function indexAction(Request $request)
    {
        $userManager = $this->get('hackzilla_ticket.user');
        $translator = $this->get('translator');

        $ticketState = $request->get('state', $translator->trans('STATUS_OPEN'));

        $repositoryTicket = $this->getDoctrine()
                ->getRepository('HackzillaTicketBundle:Ticket');

        $repositoryTicketMessage = $this->getDoctrine()
                ->getRepository('HackzillaTicketBundle:TicketMessage');

        $query = $repositoryTicket->getTicketList($userManager, $repositoryTicketMessage->getTicketStatus($translator, $ticketState));

        $paginator = $this->get('knp_paginator');
        $pagination = $paginator->paginate(
            $query->getQuery(),
            $request->query->get('page', 1)/*page number*/,
            10/*limit per page*/
        );

        return $this->render('HackzillaTicketBundle:Ticket:index.html.twig', array(
                    'pagination' => $pagination,
                    'ticketState' => $ticketState,
        ));
    }

    /**
     * Creates a new Ticket entity.
     *
     */
    public function createAction(Request $request)
    {
        $userManager = $this->get('hackzilla_ticket.user');

        $ticket = new Ticket();
        $form = $this->createForm(new TicketType($userManager), $ticket);
        $form->handleRequest($request);

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

            $message = $ticket->getMessages()->current();
            $message->setStatus(TicketMessage::STATUS_OPEN);
            $message->setUser($userManager->getCurrentUser());
            $message->setTicket($ticket);

            $em->persist($ticket);
            $em->persist($message);

            $em->flush();

            return $this->redirect($this->generateUrl('hackzilla_ticket_show', array('id' => $ticket->getId())));
        }

        return $this->render('HackzillaTicketBundle:Ticket:new.html.twig', array(
                    'entity' => $ticket,
                    'form' => $form->createView(),
        ));
    }

    /**
     * Displays a form to create a new Ticket entity.
     *
     */
    public function newAction()
    {
        $entity = new Ticket();
        $userManager = $this->get('hackzilla_ticket.user');
        $form = $this->createForm(new TicketType($userManager), $entity);

        return $this->render('HackzillaTicketBundle:Ticket:new.html.twig', array(
                    'entity' => $entity,
                    'form' => $form->createView(),
        ));
    }

    /**
     * Finds and displays a Ticket entity.
     *
     */
    public function showAction(Ticket $ticket)
    {
        $userManager = $this->get('hackzilla_ticket.user');
        $this->checkUserPermission($userManager->getCurrentUser(), $ticket);

        $data = array('ticket' => $ticket);

        $message = new TicketMessage();
        $message->setPriority($ticket->getPriority());
        $message->setStatus($ticket->getStatus());

        if (TicketMessage::STATUS_CLOSED != $ticket->getStatus()) {
            $data['form'] = $this->createForm(new TicketMessageType($userManager), $message)->createView();
        }

        $data['delete_form'] = $this->createDeleteForm($ticket->getId())->createView();

        return $this->render('HackzillaTicketBundle:Ticket:show.html.twig', $data);
{'fraction_non_alphanumeric': 0.15546486417548783, 'fraction_numerical': 0.0007652085193215151, 'mean_word_length': 2.6644859813084114, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 125, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5192671', 'n_tokens_mistral': 2351, 'n_tokens_neox': 2207, 'n_words': 338}