src/Controller/Web/AbstractInformationController.php line 74

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Controller\Web;
  3. use App\Repository\RewardRepository;
  4. use FOS\RestBundle\Controller\Annotations as Rest;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  6. use Swagger\Annotations as SWG;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use App\Helper\PimcoreCMSHelper;
  10. abstract class AbstractInformationController extends AbstractController
  11. {
  12.     /**
  13.      * @var RewardRepository
  14.      */
  15.     protected $rewardRepository;
  16.     public function __construct(RewardRepository $rewardRepository)
  17.     {
  18.         $this->rewardRepository $rewardRepository;
  19.     }
  20.     /**
  21.      * @Rest\Get("/bonus-card")
  22.      * @Cache(expires="tomorrow", public=true)
  23.      *
  24.      * @SWG\Response(
  25.      *     response=200,
  26.      *     description="Html content",
  27.      *     @SWG\Schema(type="array", items=@SWG\Items()))
  28.      *
  29.      * @return \Symfony\Component\HttpFoundation\Response
  30.      */
  31.     public function bonusCardAction(RewardRepository $rewardRepositoryPimcoreCMSHelper $pimcoreCMSHelper)
  32.     {
  33.         $html 'web/information.d/bonus-card.html.twig';
  34.         switch (getenv('APP_COUNTRY')) {
  35.             case 'hrv':
  36.                 $html 'web/information.d/bonus-card.hr.html.twig';
  37.                 break;
  38.             case 'svn':
  39.                 $html 'web/information.d/bonus-card.sl.html.twig';
  40.                 break;
  41.             case 'srb':
  42.                 $html 'web/information.d/bonus-card.rs.html.twig';
  43.                 break;
  44.             case 'rks':
  45.                 $html 'web/information.d/bonus-card.ks.html.twig';
  46.                 break;
  47.             case 'alb':
  48.                 $html 'web/information.d/bonus-card.al.html.twig';
  49.                 break;
  50.             case 'grc':
  51.                 $html 'web/information.d/bonus-card.el.html.twig';
  52.                 break;
  53.             case 'mkd':
  54.                 $html 'web/information.d/bonus-card.mk.html.twig';
  55.                 break;
  56.             case 'mne':
  57.                 $html 'web/information.d/bonus-card.me.html.twig';
  58.                 break;
  59.             default:
  60.                 $html 'web/information.d/bonus-card.html.twig';
  61.         }
  62.         // Fetch dynamic content from CMS
  63.         $data $pimcoreCMSHelper->fetchCMSContent(strtoupper(getenv('APP_COUNTRY')));
  64.         $rewards $rewardRepository->findAll() ? ['rewards' => $rewardRepository->findAll()] : [];
  65.         return $this->render(
  66.             $html,
  67.             array_merge($rewards$data)
  68.         );
  69.     }
  70.     /**
  71.      * @param Request $request
  72.      *
  73.      * @return \Symfony\Component\HttpFoundation\Response
  74.      */
  75.     abstract public function impressumAction(Request $request);
  76.     /**
  77.      * @param Request $request
  78.      *
  79.      * @return \Symfony\Component\HttpFoundation\Response
  80.      */
  81.     abstract public function developerAction(Request $request);
  82.     /**
  83.      * @param Request $request
  84.      *
  85.      * @return \Symfony\Component\HttpFoundation\Response
  86.      */
  87.     abstract public function b2bAction(Request $request);
  88.     protected function getLocaleFromRequest(Request $request){
  89.         $locale $request->query->get('locale');
  90.         if(empty($locale)){
  91.             $locale=$request->getLocale();
  92.         }
  93.         return $locale;
  94.     }
  95. }