<?php
namespace App\Controller;
use App\Entity\Faq;
use App\Entity\Features;
use App\Entity\Subscribe;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\String\ByteString;
class PricesController extends AbstractController
{
protected $em;
public function __construct(EntityManagerInterface $entityManager)
{
$this->em = $entityManager;
}
/**
* @Route("/prices", name="app_prices")
*/
public function index(): Response
{
$category = null;
$subscribes = $this->em->getRepository(Subscribe::class)->findBy(["statut"=>1, "default_sub"=>1]);
$features = $this->em->getRepository(Features::class)->findBy(["statut"=>1], ["position"=>"ASC"]);
$faq = $this->em->getRepository(Faq::class)->findBy(["statut"=>1], ["position"=>"ASC"]);
if(!empty($features)){
foreach($features as $feature):
if(!empty($feature->getCategoryName())){
$category[$feature->getId()] = $feature->getCategoryName();
}
endforeach;
}
return $this->render('prices/index.html.twig', [
'faq' => $faq,
'features' => $features,
'categoryFeatures' => $category,
'subscribes' => $subscribes,
'hashSales' => (new ByteString)->fromRandom(15)->toString()
]);
}
}