<?php
namespace App\Controller\Front;
use App\Manager\{HomeManager, AboutManager};
use App\Manager\{CategoryManager, ServiceManager, StoreManager, InfoStoreManager};
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController
{
protected array $locals = [];
public function __construct()
{
$this->locals['menu_active'] = '';
}
/**
* @Route("/", name="home")
* @Template("front/default/home.html.twig")
*/
public function home(HomeManager $hm, CategoryManager $cm, ServiceManager $sm): array
{
$this->locals['home'] = $hm->find(1);
$this->locals['categoriesHome'] = $cm->listActiveHome();
$this->locals['servicesHome'] = $sm->listActiveHome();
$this->locals['menu_active'] = 'home';
return $this->locals;
}
/**
* @Route("/nosotros/", name="about")
* @Template("front/default/about.html.twig")
*/
public function about(AboutManager $am): array
{
$this->locals['home'] = $am->find(1);
return $this->locals;
}
/**
* @Route("/locales/{slug}/", name="store_detail")
* @Template("front/default/stores.html.twig")
*/
public function storesDetail(InfoStoreManager $ism, StoreManager $sm, $slug): array
{
$this->locals['home'] = $ism->find(1);
$this->locals['stores'] = $sm->listActive();
$this->locals['detail'] = $sm->findBySlug($slug);
$this->locals['menu_active'] = 'stores';
return $this->locals;
}
/**
* @Route("/locales/", name="stores")
* @Template("front/default/stores.html.twig")
*/
public function stores(InfoStoreManager $ism, StoreManager $sm): array
{
$this->locals['home'] = $ism->find(1);
$this->locals['stores'] = $sm->listActive();
$this->locals['detail'] = $sm->findBySlug(null);
$this->locals['menu_active'] = 'stores';
return $this->locals;
}
}