src/Controller/FrontController.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\ShortCodeService;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class FrontController extends AbstractController
  8. {
  9.     /**
  10.      * @Route("/{short_code}", name="app_front_index")
  11.      *
  12.      * @param ShortCodeService $shortCodeService
  13.      * @param $short_code
  14.      * @return Response
  15.      */
  16.     public function index(ShortCodeService $shortCodeService$short_code): Response
  17.     {
  18.         $redirect_to_url $shortCodeService->getShortCode($short_code);
  19.         if(!is_null($redirect_to_url)) {
  20.             $shortCodeService->addShortCodeVisit($short_code);
  21.             return $this->redirect($redirect_to_url);
  22.         }
  23.         return $this->render('http/404.html.twig', [
  24.             'controller_name' => 'HttpController',
  25.         ]);
  26.     }
  27. }