src/Infrastructure/Controller/Website/Istanza/NewController.php line 17
<?phpdeclare(strict_types=1);namespace App\Infrastructure\Controller\Website\Istanza;use App\Infrastructure\Controller\Website\BaseWebsiteControllerInterface;use App\Infrastructure\Factory\Pratica\PraticaFactoryInterface;use App\Infrastructure\Repository\Istanza\IstanzaRepositoryInterface;use App\Infrastructure\Repository\Pratica\PraticaRepositoryInterface;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;use Symfony\Component\Routing\Annotation\Route;final class NewController extends AbstractController implements BaseWebsiteControllerInterface{public function __construct(private readonly PraticaFactoryInterface $praticaFactory,private readonly PraticaRepositoryInterface $praticaRepository,private readonly IstanzaRepositoryInterface $istanzaRepository,) {}/*** CREAZIONE PRATICA TEMPORANEA DA ISTANZA*/#[Route('/istanza/{slug}', name: 'app_website_istanza_new', methods: ['GET'])]public function __invoke(Request $request, string $slug): Response{$istanza = $this->istanzaRepository->findBySlug($slug);if (!$istanza || !$istanza->isAttivo()) {throw new NotFoundHttpException();}// @TODO: completare e creare servizio separato$pratica = $this->praticaFactory->create($istanza);$pratica->setIpRichiedente($request->getClientIp());$pratica = $this->praticaRepository->save($pratica);return $this->redirectToRoute('app_website_istanza_new_privacy',['slug' => $istanza->getSlug(),'id' => $pratica->getId(),]);}}