feat(controller): add details controller

This commit is contained in:
Ondrej Vlach 2024-08-03 20:37:29 +02:00
parent 0bff14f820
commit 893ad31abc
No known key found for this signature in database
GPG Key ID: 7F141CDACEDEE2DE

View File

@ -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');
}