<?php
namespace App\Controller;
use App\Entity\Post;
use App\Entity\Photo;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManagerInterface;
class AboutController extends AbstractController
{
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
#[Route('/about', name: 'about_me')]
public function about(): Response
{
// Получение статьи "Обо мне" из базы данных
$post = $this->entityManager->getRepository(Post::class)->findOneBy(['title' => 'Обо мне']);
$photo = $this->entityManager->getRepository(Photo::class)->findOneBy(['description' => 'обо мне фото']);
return $this->render('post/about_me.html.twig', [
'post' => $post,
'photo' => $photo,
]);
}
}