src/Controller/BridgeController.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Garages\Garage;
  4. use App\Entity\Tires\Tire;
  5. use App\Enum\SiteEnum;
  6. use App\Repository\Promotions\LocalPromotionRepository;
  7. use App\Repository\Promotions\NationalPromotionRepository;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  11. use Symfony\Component\HttpFoundation\RedirectResponse;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use Symfony\Contracts\Translation\TranslatorInterface;
  16. /**
  17.  * Controller that renders code snippets to be called via "curl" from Vulco legacy code.
  18.  *
  19.  * @Route("/render")
  20.  */
  21. class BridgeController extends AbstractController
  22. {
  23.     /**
  24.      * @Route("/garage-national-promotions/{id}", name="garage_national_promotions", methods={"GET"})
  25.      * @ParamConverter("garage", class="App\Entity\Garages\Garage", options={"mapping": {"id": "id"}})
  26.      */
  27.     public function garageNationalPromotions(Garage $garageNationalPromotionRepository $nationalPromotionRepository): Response
  28.     {
  29.         $nationalPromotions $nationalPromotionRepository->findCurrentByGarage($garage);
  30.         if ($nationalPromotions) {
  31.             return $this->render('bridge/garage_national_promotions.html.twig', [
  32.                 'national_promotions' => $nationalPromotions,
  33.             ]);
  34.         }
  35.         return $this->render('bridge/empty.html.twig');
  36.     }
  37.     /**
  38.      * @Route("/garage-local-promotions/{id}", name="garage_local_promotions", methods={"GET"})
  39.      * @ParamConverter("garage", class="App\Entity\Garages\Garage", options={"mapping": {"id": "id"}})
  40.      */
  41.     public function garageLocalPromotions(Garage $garageLocalPromotionRepository $localPromotionRepository): Response
  42.     {
  43.         $localPromotions $localPromotionRepository->getActiveByGarage($garage);
  44.         if ($localPromotions) {
  45.             return $this->render('bridge/garage_local_promotions.html.twig', [
  46.                 'local_promotions' => $localPromotions,
  47.             ]);
  48.         }
  49.         return $this->render('bridge/empty.html.twig');
  50.     }
  51.     /**
  52.      * @Route("/legacy-frontend-garage-detail/{id}/redirect", name="legacy_frontend_garage_detail_redirect", methods={"GET"})
  53.      * @ParamConverter("garage", class="App\Entity\Garages\Garage", options={"mapping": {"id": "id"}})
  54.      */
  55.     public function legacyFrontendGarageDetailRedirect(Garage $garageParameterBagInterface $pbRequest $request): RedirectResponse
  56.     {
  57.         $base $pb->get('old_frontend_uri_es');
  58.         if (SiteEnum::SITE_STR_PT === $request->getLocale()) {
  59.             $base $pb->get('old_frontend_uri_pt');
  60.         }
  61.         return $this->redirect($base.$garage->getSlug());
  62.     }
  63.     /**
  64.      * @Route("/legacy-backend-garage-edit/{id}/redirect", name="legacy_backend_garage_edit_redirect", methods={"GET"})
  65.      * @ParamConverter("garage", class="App\Entity\Garages\Garage", options={"mapping": {"id": "id"}})
  66.      */
  67.     public function legacyBackendGarageDetailRedirect(Garage $garageParameterBagInterface $pbRequest $request): RedirectResponse
  68.     {
  69.         $base $pb->get('old_frontend_uri_es');
  70.         if (SiteEnum::SITE_STR_PT === $request->getLocale()) {
  71.             $base $pb->get('old_frontend_uri_pt');
  72.         }
  73.         return $this->redirect($base.'admin/garage/'.$garage->getId().'/edit');
  74.     }
  75.     /**
  76.      * @Route("/legacy-frontend-tire-detail/{slug}/redirect", name="legacy_frontend_tire_detail_redirect", methods={"GET"})
  77.      * @ParamConverter("tire", class="App\Entity\Tires\Tire", options={"mapping": {"slug": "slug"}})
  78.      */
  79.     public function legacyFrontendTireDetailRedirect(Tire $tireTranslatorInterface $translatorParameterBagInterface $pbRequest $request): RedirectResponse
  80.     {
  81.         $base $pb->get('old_frontend_uri_es');
  82.         if (SiteEnum::SITE_STR_PT === $request->getLocale()) {
  83.             $base $pb->get('old_frontend_uri_pt');
  84.         }
  85.         return $this->redirect($base.$translator->trans('tires.list.show_uri').'/'.$tire->getSlug());
  86.     }
  87. }