<?php
namespace App\Controller;
use App\Entity\AboutPageData;
use App\Services\AboutService;
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 AboutController extends AbstractController
{
#[Route('/about', name: 'app_about_us')]
public function index(EntityManagerInterface $entityManager): Response
{
$data = $entityManager->getRepository(AboutPageData::class)->find(AboutPageData::ABOUT_DATA_ID);
return $this->render('about_us/index.html.twig', [
'data' => $data
]);
}
#[Route('/about/edit', name: 'app_about_us_edit')]
public function EditPage(Request $request, EntityManagerInterface $entityManager)
{
$service = new AboutService();
$service->EditAboutPage($request, $entityManager);
$data = $entityManager->getRepository(AboutPageData::class)->find(AboutPageData::ABOUT_DATA_ID);
return $this->render('about_us/edit_form.html.twig', [
'data' => $data
]);
}
#[Route('/about/question', name: 'app_about_us_ask_question')]
public function AskQuestion(Request $request, EntityManagerInterface $entityManager)
{
$user = $this->getUser();
$service = new AboutService();
$service->AskQuestion($request, $entityManager, $user);
return $this->render('about_us/ask_question_form.html.twig');
}
}