<?php
namespace App\Controller;
use App\Entity\Taxonomy\Taxon;
use Doctrine\Persistence\ManagerRegistry;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Channel\Model\ChannelInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
/**
* @property ManagerRegistry $manager
*/
class FooterController extends AbstractController
{
private ChannelInterface $channel;
public function __construct(ManagerRegistry $registry, ChannelContextInterface $channelContext)
{
$this->manager = $registry;
$this->channel = $channelContext->getChannel();
}
public function getFooterTaxonAction(): Response
{
if (!$root = $this->channel->getMenuTaxon()) {
$root = $this->manager->getRepository(Taxon::class)->findOneBy(['parent' => NULL]);
}
return $this->render('footer/_taxons.html.twig', [
'taxons' => $root->getEnabledChildren()
]);
}
}