src/Controller/Frontend/ComponentController.php line 25

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of Symfony Keen Template Project.
  4.  * (c) 2021 One AM SRL
  5.  */
  6. namespace App\Controller\Frontend;
  7. use App\Entity\Component;
  8. use App\Twig\AppExtension;
  9. use Keen\Attribute\Breadcrumb;
  10. use Keen\Attribute\NavbarTag;
  11. use Keen\Event\Listener\BreadcrumbAnnotationListener;
  12. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. #[NavbarTag('component')]
  17. #[Route(path'/componenti'name'frontend_component_'methods: ['GET'])]
  18. class ComponentController extends AbstractController
  19. {
  20.     #[Route(path''name'list'methods: ['GET'])]
  21.     public function list(AppExtension $appExtensionBreadcrumbAnnotationListener $annotationListener): Response
  22.     {
  23.         $annotationListener->addBreadcrumb(new Breadcrumb('Componenti'));
  24.         return $this->render('frontend/component/list.html.twig', [
  25.             'componentConfiguration' => $appExtension->componentConfiguration(),
  26.         ]);
  27.     }
  28.     #[Route(path'/{component}'name'index'methods: ['GET'])]
  29.     #[Entity('component'expr'repository.findOneBySlug(component)')]
  30.     public function index(Component $componentBreadcrumbAnnotationListener $annotationListener): Response
  31.     {
  32.         $annotationListener->addBreadcrumb(new Breadcrumb('Componenti''frontend_component_list'));
  33.         $annotationListener->addBreadcrumb(new Breadcrumb($component->getName()));
  34.         return $this->render('frontend/component/index.html.twig', [
  35.             'component' => $component,
  36.         ]);
  37.     }
  38. }