From 893ad31abca7760d10e6c2a75e76ca826bb78640 Mon Sep 17 00:00:00 2001 From: Ondrej Vlach Date: Sat, 3 Aug 2024 20:37:29 +0200 Subject: [PATCH] feat(controller): add details controller --- src/Controller/DetailPostController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Controller/DetailPostController.php b/src/Controller/DetailPostController.php index 0f31694..bee8947 100644 --- a/src/Controller/DetailPostController.php +++ b/src/Controller/DetailPostController.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Controller; use App\Repository\Post\PostRepository; +use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -14,6 +15,7 @@ final class DetailPostController extends AbstractController { public function __construct( private readonly PostRepository $postRepository, + private readonly LoggerInterface $logger, ) { } @@ -23,6 +25,7 @@ final class DetailPostController extends AbstractController $post = $this->postRepository->find($postId); if ($post === null) { + $this->logger->error('Post not found', ['postId' => $postId]); throw new NotFoundHttpException('Post not found. Please check the provided ID. If the problem persists, contact the system administrator'); }