<?php
/**
* This file is part of Symfony Keen Template Project.
* (c) 2021 One AM SRL
*/
namespace App\Controller\Frontend;
use App\Entity\Component;
use App\Twig\AppExtension;
use Keen\Attribute\Breadcrumb;
use Keen\Attribute\NavbarTag;
use Keen\Event\Listener\BreadcrumbAnnotationListener;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[NavbarTag('component')]
#[Route(path: '/componenti', name: 'frontend_component_', methods: ['GET'])]
class ComponentController extends AbstractController
{
#[Route(path: '', name: 'list', methods: ['GET'])]
public function list(AppExtension $appExtension, BreadcrumbAnnotationListener $annotationListener): Response
{
$annotationListener->addBreadcrumb(new Breadcrumb('Componenti'));
return $this->render('frontend/component/list.html.twig', [
'componentConfiguration' => $appExtension->componentConfiguration(),
]);
}
#[Route(path: '/{component}', name: 'index', methods: ['GET'])]
#[Entity('component', expr: 'repository.findOneBySlug(component)')]
public function index(Component $component, BreadcrumbAnnotationListener $annotationListener): Response
{
$annotationListener->addBreadcrumb(new Breadcrumb('Componenti', 'frontend_component_list'));
$annotationListener->addBreadcrumb(new Breadcrumb($component->getName()));
return $this->render('frontend/component/index.html.twig', [
'component' => $component,
]);
}
}