feat(controller): add details controller
This commit is contained in:
		
							parent
							
								
									0bff14f820
								
							
						
					
					
						commit
						893ad31abc
					
				@ -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');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user