src/Hitso/Bundle/TicketsBundle/Controller/Front/TicketController.php line 35

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Hitso\Bundle\TicketsBundle\Controller\Front;
  4. use Hitso\Bundle\CommonBundle\Controller\Controller;
  5. use Hitso\Bundle\SeoBundle\Entity\SeoPage;
  6. use Hitso\Bundle\TicketsBundle\Entity\Status;
  7. use Hitso\Bundle\TicketsBundle\Entity\Ticket;
  8. use Hitso\Bundle\TicketsBundle\Manager\ContactManager;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use WhiteOctober\BreadcrumbsBundle\Model\Breadcrumbs;
  13. /**
  14.  * @Route("/contact", name="hitso_tickets_front_")
  15.  */
  16. class TicketController extends Controller
  17. {
  18.     /**
  19.      * @var ContactManager
  20.      */
  21.     protected $contactManager;
  22.     public function __construct(ContactManager $contactManager)
  23.     {
  24.         $this->contactManager $contactManager;
  25.     }
  26.     /**
  27.      * @Route("/", name="index")
  28.      */
  29.     public function indexAction(Breadcrumbs $breadcrumbsRequest $request): Response
  30.     {
  31.         $breadcrumbs->addRouteItem('Contact''hitso_tickets_front_index');
  32.         /** @var Ticket $ticket */
  33.         $ticket $this->contactManager->initResource();
  34.         $form   $this->contactManager->initForm($ticket);
  35.         $form->handleRequest($request);
  36.         if ($form->isSubmitted() && $form->isValid()) {
  37.             $status $this->getDoctrine()->getRepository(Status::class)->find(Status::CREATED);
  38.             $ticket->setStatus($status);
  39.             $this->contactManager->createResource($ticket);
  40.             return $this->redirectToAction('confirm');
  41.         }
  42.         $content $this->getManagerForClass(SeoPage::class)->getRepository()->findOneBy(['route' => 'hitso_tickets_front_index']);
  43.         if ($content) {
  44.             $this->updateSeoPage($content);
  45.         }
  46.         return $this->displayTemplate('index', [
  47.             'form' => $form->createView(),
  48.         ]);
  49.     }
  50.     /**
  51.      * @Route("/confirm", name="confirm")
  52.      */
  53.     public function confirmAction(Breadcrumbs $breadcrumbs)
  54.     {
  55.         $breadcrumbs->addRouteItem('Contact''hitso_tickets_front_index');
  56.         $breadcrumbs->addRouteItem('Confirmation''hitso_tickets_front_confirm');
  57.         return $this->displayTemplate('confirm');
  58.     }
  59. }