<?php
namespace App\V4\Controller\Tab;
use App\Model\Form\FormSchema;
use App\V4\Service\Tab\TabFormHandler;
use App\V4\Voters\TabVoter;
use ReflectionException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
class GetTabFormAction extends AbstractController
{
/**
* @var TabFormHandler
*/
private $tabFormHandler;
/**
* @param TabFormHandler $tabFormHandler
*/
public function __construct(TabFormHandler $tabFormHandler)
{
$this->tabFormHandler = $tabFormHandler;
}
/**
* @param Request $request
* @param string|null $id
*
* @return FormSchema|array
*
* @throws ClientExceptionInterface
* @throws DecodingExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ReflectionException
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function __invoke(Request $request, string $id = null)
{
$this->denyAccessUnlessGranted(TabVoter::TAB_ADD_EDIT);
return $this->tabFormHandler->getTabForm($id, $request->get('customerId'));
}
}