Problema resuelto, resulta que me faltaba importar el response.php de Symfony para que andara bien.
Código PHP:
Ver original<?php
namespace UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use \UserBundle\Entity\Task;
use \UserBundle\Form\TaskType;
class TaskController extends Controller
{
...........
public function customAction(Request $request) {
$idUser = $this->get('security.token_storage')->getToken()->getUser()->getId();
$em = $this->getDoctrine()->getManager();
$dql = "SELECT t FROM UserBundle:Task t JOIN t.user u WHERE u.id = :idUser ORDER BY t.id DESC";
$tasks = $em->createQuery($dql)->setParameter('idUser' , $idUser);
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$tasks,
$request->query->getInt('page', 1),
3
);
$updateForm = $this->createCustomForm(':TASK_ID', 'PUT', 'task_process');
return $this->render('UserBundle:Task:custom.html.twig',[
'pagination' => $pagination,
'update_form' => $updateForm->createView()
]);
}
public function processAction($id, Request $request) {
$em = $this->getDoctrine()->getManager();
$task = $em->getRepository('UserBundle:Task')->find($id);
if(!$task) {
throw $this>createNotFoundException('La tarea no existe');
}
$form = $this->createCustomForm($task->getId(), 'PUT', 'task_process');
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()) {
$success = $this->get('translator')->trans('The task has been processed.');
$warning = $this->get('translator')->trans('The task has already been processed.');
if ($task->getStatus() == 0) {
$task->setStatus(1);
if($request->isXMLHttpRequest()) {
return new Response(
json_encode(['processed' => 1, 'success' => $success]), 200,
array('Content-Type' => 'application/json') );
}
} else {
if($request->isXMLHttpRequest()) {
return new Response(
json_encode(['processed' => 0, 'warning' => $warning]), 200,
array('Content-Type' => 'application/json') );
}
}
}
}
}
Pongo lo que se necesita del controlador para que ande lo de jquery por si alguien lo quiere.
Saludos