<?php
namespace App\Controller;
use App\Entity\Menu;
use App\Entity\MenuOpcio;
use App\Entity\Usuari;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Translation\LocaleSwitcher;
class MenuController extends AbstractController
{
private $em;
public function __construct(private LocaleSwitcher $localeSwitcher, EntityManagerInterface $em)
{
$this->em = $em;
}
public function indexAction(Request $peticion)
{
$aParam = array('principal' => 1);
$objMenu = $this->em->getRepository(Menu::class)->findBy($aParam, array(), 1);
$objMenuOpcio = $this->em->getRepository(MenuOpcio::class)->findBy(
array(
"parent" => null,
"menu" => $objMenu[0]->getId()
),
array(
"ordre" => "ASC")
);
return $this->render('webMenu.html.twig', array(
'objMenu' => $objMenu,
'objMenuOpcio' => $objMenuOpcio,
'level' => 0,
'actual' => $objMenu[0]->getId(),
'parentDisabled'=> 0
));
}
public function menuListAction($isMobileVersion=false)
{
$repository = $this->em->getRepository(Menu::class);
$list = $repository->getSecciones();
return $this->render('menuList.html.twig', array(
"isMobileVersion" => $isMobileVersion,
"list" => $list
));
}
}