src/Controller/PricesController.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Faq;
  4. use App\Entity\Features;
  5. use App\Entity\Subscribe;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\String\ByteString;
  11. class PricesController extends AbstractController
  12. {
  13.     protected $em;
  14.     public function __construct(EntityManagerInterface $entityManager)
  15.     {
  16.         $this->em $entityManager;
  17.     }
  18.     
  19.     /**
  20.      * @Route("/prices", name="app_prices")
  21.      */
  22.     public function index(): Response
  23.     {
  24.         $category null;
  25.         $subscribes $this->em->getRepository(Subscribe::class)->findBy(["statut"=>1"default_sub"=>1]);
  26.         $features $this->em->getRepository(Features::class)->findBy(["statut"=>1], ["position"=>"ASC"]);
  27.         $faq $this->em->getRepository(Faq::class)->findBy(["statut"=>1], ["position"=>"ASC"]);
  28.         if(!empty($features)){
  29.             foreach($features as $feature):
  30.                 if(!empty($feature->getCategoryName())){
  31.                     $category[$feature->getId()] = $feature->getCategoryName();
  32.                 }
  33.             endforeach;
  34.         }
  35.         
  36.         return $this->render('prices/index.html.twig', [
  37.             'faq'               => $faq,
  38.             'features'          => $features,
  39.             'categoryFeatures'  => $category,
  40.             'subscribes'         => $subscribes,
  41.             'hashSales'     => (new ByteString)->fromRandom(15)->toString()
  42.         ]);
  43.     }
  44. }