src/Controller/AboutController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Post;
  4. use App\Entity\Photo;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. class AboutController extends AbstractController
  10. {
  11.   private $entityManager;
  12.   public function __construct(EntityManagerInterface $entityManager)
  13.   {
  14.     $this->entityManager $entityManager;
  15.   }
  16.   #[Route('/about'name'about_me')]
  17.   public function about(): Response
  18.   {
  19.     // Получение статьи "Обо мне" из базы данных
  20.     $post $this->entityManager->getRepository(Post::class)->findOneBy(['title' => 'Обо мне']);
  21.     $photo $this->entityManager->getRepository(Photo::class)->findOneBy(['description' => 'обо мне фото']);
  22.     return $this->render('post/about_me.html.twig', [
  23.       'post' => $post,
  24.       'photo' => $photo,
  25.     ]);
  26.   }
  27. }