<commit_before><?php

namespace AppBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use AppBundle\Entity\Tasks;
use AppBundle\Form\TasksType;

/**
 * Tasks controller.
 *
 * @Route("/tasks")
 */
class TasksController extends Controller
{

  /**
   * Lists all Tasks entities.
   *
   * @Route("/", name="tasks_index")
   * @Method("GET")
   */
  public function indexAction()
  {
    $em = $this->getDoctrine()->getManager();

    $tasks = $em->getRepository('AppBundle:Tasks')->findAll();

    return $this->render('tasks/index.html.twig', array(
          'tasks' => $tasks,
    ));
  }

  /**
   * Advanced Lists all Tasks entities.
   *
   * @Route("/advanced", name="tasks_advanced")
   * @Method({"GET", "POST"})
   */
  public function advancedAction(Request $request)
  {
    $em = $this->getDoctrine()->getManager();

    $tasks = $em->getRepository('AppBundle:Tasks')->findBy(array(
      "completed" => false
        ), array(
      "priority" => "DESC",
      "urgency" => "DESC",
      "order" => "ASC",
      "est" => "ASC"
    ));

    return $this->render('tasks/advanced.html.twig', array(
          'tasks' => $tasks,
    ));
  }

  /**
   * Creates a new Tasks entity.
   *
   * @Route("/new", name="tasks_new")
   * @Method({"GET", "POST"})
   */
  public function newAction(Request $request)
  {
    $em = $this->getDoctrine()->getManager();
    $task = new Tasks();
    if (!empty($request->get("tasklist"))) {
      $taskList = $em->getRepository('AppBundle:TaskLists')->find($request->get("tasklist"));
      $task->setTaskList($taskList);
    }
    $form = $this->createForm(TasksType::class, $task);
    $form->handleRequest($request);

    if ($form->isSubmitted() && $form->isValid()) {
      if ($task->getCompleted()) {
        $task->setCompletedAt(new \DateTime());
      } else {
        $task->setCompletedAt(null);
      }
      $em->persist($task);
      $em->flush();

      return $this->redirectToRoute('tasks_show', array('id' => $task->getId()));
//            return $this->redirectToRoute('focus');
    }

    return $this->render('tasks/new.html.twig', array(
          'task' => $task,
          'task_form' => $form->createView(),
    ));
  }

  /**
   * Displays a form to edit an existing Tasks entity.
   *
   * @Route("/order", name="tasks_order")
   * @Method("POST")
   */
  public function orderAction(Request $request)
  {
    $em = $this->getDoctrine()->getManager();

    if ($request->isXMLHttpRequest()) {
      $tasks = $request->get('tasks');
      foreach ($tasks as $order => $taskId) {
        $task = $em->find(Tasks::class, $taskId);
        if ($task) {
          $task->setOrder($order);
        }
      }
      $em->flush();
      return new \Symfony\Component\HttpFoundation\JsonResponse();
    }
  }

  /**
   * Finds and displays a Tasks entity.
   *
   * @Route("/{id}", name="tasks_show")
   * @Method("GET")
   */
  public function showAction(Tasks $tasks)
  {
    $deleteForm = $this->createDeleteForm($tasks);

    return $this->render('tasks/show.html.twig', array(
          'task' => $tasks,
          'delete_form' => $deleteForm->createView(),
    ));
  }

  /**
   * Displays a form to edit an existing Tasks entity.
   *
   * @Route("/{id}/edit", name="tasks_edit")
   * @Method({"GET", "POST"})
   */
  public function editAction(Request $request, Tasks $task)
  {
    $em = $this->getDoctrine()->getManager();


    if ($request->isXMLHttpRequest()) {

      if ($request->get('postpone')) {
        $task->setEta(new \DateTime('tomorrow'));
      }

      if ($request->get('undo')) {
        $task->setEta(null);
      }

      dump($task->getEta());

      $task->setCompleted($request->get('completed'));
      if ($task->getCompleted()) {
        $task->setCompletedAt(new \DateTime());
      } else {
        $task->setCompletedAt(null);
      }<commit_msg>Remove dump value in TaskController.php<commit_after><?php

namespace AppBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use AppBundle\Entity\Tasks;
use AppBundle\Form\TasksType;

/**
 * Tasks controller.
 *
 * @Route("/tasks")
 */
class TasksController extends Controller
{

  /**
   * Lists all Tasks entities.
   *
   * @Route("/", name="tasks_index")
   * @Method("GET")
   */
  public function indexAction()
  {
    $em = $this->getDoctrine()->getManager();

    $tasks = $em->getRepository('AppBundle:Tasks')->findAll();

    return $this->render('tasks/index.html.twig', array(
          'tasks' => $tasks,
    ));
  }

  /**
   * Advanced Lists all Tasks entities.
   *
   * @Route("/advanced", name="tasks_advanced")
   * @Method({"GET", "POST"})
   */
  public function advancedAction(Request $request)
  {
    $em = $this->getDoctrine()->getManager();

    $tasks = $em->getRepository('AppBundle:Tasks')->findBy(array(
      "completed" => false
        ), array(
      "priority" => "DESC",
      "urgency" => "DESC",
      "order" => "ASC",
      "est" => "ASC"
    ));

    return $this->render('tasks/advanced.html.twig', array(
          'tasks' => $tasks,
    ));
  }

  /**
   * Creates a new Tasks entity.
   *
   * @Route("/new", name="tasks_new")
   * @Method({"GET", "POST"})
   */
  public function newAction(Request $request)
  {
    $em = $this->getDoctrine()->getManager();
    $task = new Tasks();
    if (!empty($request->get("tasklist"))) {
      $taskList = $em->getRepository('AppBundle:TaskLists')->find($request->get("tasklist"));
      $task->setTaskList($taskList);
    }
    $form = $this->createForm(TasksType::class, $task);
    $form->handleRequest($request);

    if ($form->isSubmitted() && $form->isValid()) {
      if ($task->getCompleted()) {
        $task->setCompletedAt(new \DateTime());
      } else {
        $task->setCompletedAt(null);
      }
      $em->persist($task);
      $em->flush();

      return $this->redirectToRoute('tasks_show', array('id' => $task->getId()));
//            return $this->redirectToRoute('focus');
    }

    return $this->render('tasks/new.html.twig', array(
          'task' => $task,
          'task_form' => $form->createView(),
    ));
  }

  /**
   * Displays a form to edit an existing Tasks entity.
   *
   * @Route("/order", name="tasks_order")
   * @Method("POST")
   */
  public function orderAction(Request $request)
  {
    $em = $this->getDoctrine()->getManager();

    if ($request->isXMLHttpRequest()) {
      $tasks = $request->get('tasks');
      foreach ($tasks as $order => $taskId) {
        $task = $em->find(Tasks::class, $taskId);
        if ($task) {
          $task->setOrder($order);
        }
      }
      $em->flush();
      return new \Symfony\Component\HttpFoundation\JsonResponse();
    }
  }

  /**
   * Finds and displays a Tasks entity.
   *
   * @Route("/{id}", name="tasks_show")
   * @Method("GET")
   */
  public function showAction(Tasks $tasks)
  {
    $deleteForm = $this->createDeleteForm($tasks);

    return $this->render('tasks/show.html.twig', array(
          'task' => $tasks,
          'delete_form' => $deleteForm->createView(),
    ));
  }

  /**
   * Displays a form to edit an existing Tasks entity.
   *
   * @Route("/{id}/edit", name="tasks_edit")
   * @Method({"GET", "POST"})
   */
  public function editAction(Request $request, Tasks $task)
  {
    $em = $this->getDoctrine()->getManager();


    if ($request->isXMLHttpRequest()) {

      if ($request->get('postpone')) {
        $task->setEta(new \DateTime('tomorrow'));
      }

      if ($request->get('undo')) {
        $task->setEta(null);
      }

      $task->setCompleted($request->get('completed'));
      if ($task->getCompleted()) {
        $task->setCompletedAt(new \DateTime());
      } else {
        $task->setCompletedAt(null);
      }
{'fraction_non_alphanumeric': 0.19557149925779319, 'fraction_numerical': 0.0, 'mean_word_length': 2.855507868383405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 136, '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': '6072056', 'n_tokens_mistral': 2629, 'n_tokens_neox': 2568, 'n_words': 447}