src/Controller/TestimonialDefaultController.php line 47

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Annotation\CmsComponent;
  4. use App\Entity\Testimonial;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class TestimonialDefaultController extends AbstractController
  11. {
  12. /**
  13. * @CmsComponent("Embed Testimonials", active=true, routeName="embed_testimonials")
  14. */
  15. #[Route(path: '/pcgc-testimonials', name: 'embed_testimonials')]
  16. public function embedTestimonials(Request $request, EntityManagerInterface $em): \Symfony\Component\HttpFoundation\Response
  17. {
  18. $query = $em->createQuery('SELECT e FROM App:Testimonial e WHERE e.deleted = 0 AND e.active = 1');
  19. $testimonials = $query->getResult();
  20. return $this->render('@theme/testimonial/testimonials.html.twig', [
  21. 'testimonials' => $testimonials,
  22. ]);
  23. }
  24. /**
  25. * @CmsComponent("Embed Testimonial", active=true, routeName="embed_testimonial")
  26. */
  27. #[Route(path: '/pcgc-testimonials/{slug}', name: 'embed_testimonial')]
  28. public function embedTestimonial(Request $request, EntityManagerInterface $em, $slug): \Symfony\Component\HttpFoundation\Response
  29. {
  30. $testimonial = $em->getRepository(Testimonial::class)->findOneBy(['slug' => $slug]);
  31. return $this->render('@theme/testimonials/testimonial.html.twig', [
  32. 'testimonial' => $testimonial,
  33. ]);
  34. }
  35. /**
  36. * @CmsComponent("Embed Featured Testimonials", active=true, routeName="embed_featured_testimonials")
  37. */
  38. #[Route(path: '/pcgc-testimonials/featured', name: 'embed_featured_testimonials')]
  39. public function embedFeaturedTestimonials(Request $request, EntityManagerInterface $em): \Symfony\Component\HttpFoundation\Response
  40. {
  41. $testimonials = $em->getRepository(Testimonial::class)->findBy(['featured' => true]);
  42. return $this->render('@theme/testimonial/featuredSlider.html.twig', [
  43. 'testimonials' => $testimonials,
  44. ]);
  45. }
  46. }