<?php
namespace App\V4\Controller\Task;
use App\Model\Form\FormSchema;
use App\V4\Service\Task\TaskFormHandler;
use App\V4\Voters\TaskVoter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
class GetTaskSearchFormAction extends AbstractController
{
/**
* @var TaskFormHandler
*/
private $taskFormHandler;
/**
* @param TaskFormHandler $taskFormHandler
*/
public function __construct(TaskFormHandler $taskFormHandler)
{
$this->taskFormHandler = $taskFormHandler;
}
/**
* @return FormSchema|JsonResponse
*
* @throws ExceptionInterface
*/
public function __invoke(Request $request)
{
$this->denyAccessUnlessGranted(TaskVoter::TASK_SHOW_LIST);
return $this->taskFormHandler->getTaskSearchForm($request->query->get('tabId'), (bool) $request->query->get('isLegacy', false));
}
}