<?php
namespace App\Controller;
use App\Annotation\CmsComponent;
use App\Entity\Testimonial;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class TestimonialDefaultController extends AbstractController
{
/**
* @CmsComponent("Embed Testimonials", active=true, routeName="embed_testimonials")
*/
#[Route(path: '/pcgc-testimonials', name: 'embed_testimonials')]
public function embedTestimonials(Request $request, EntityManagerInterface $em): \Symfony\Component\HttpFoundation\Response
{
$query = $em->createQuery('SELECT e FROM App:Testimonial e WHERE e.deleted = 0 AND e.active = 1');
$testimonials = $query->getResult();
return $this->render('@theme/testimonial/testimonials.html.twig', [
'testimonials' => $testimonials,
]);
}
/**
* @CmsComponent("Embed Testimonial", active=true, routeName="embed_testimonial")
*/
#[Route(path: '/pcgc-testimonials/{slug}', name: 'embed_testimonial')]
public function embedTestimonial(Request $request, EntityManagerInterface $em, $slug): \Symfony\Component\HttpFoundation\Response
{
$testimonial = $em->getRepository(Testimonial::class)->findOneBy(['slug' => $slug]);
return $this->render('@theme/testimonials/testimonial.html.twig', [
'testimonial' => $testimonial,
]);
}
/**
* @CmsComponent("Embed Featured Testimonials", active=true, routeName="embed_featured_testimonials")
*/
#[Route(path: '/pcgc-testimonials/featured', name: 'embed_featured_testimonials')]
public function embedFeaturedTestimonials(Request $request, EntityManagerInterface $em): \Symfony\Component\HttpFoundation\Response
{
$testimonials = $em->getRepository(Testimonial::class)->findBy(['featured' => true]);
return $this->render('@theme/testimonial/featuredSlider.html.twig', [
'testimonials' => $testimonials,
]);
}
}