point-tools/src/Controller/PostController.php

34 lines
1.3 KiB
PHP
Raw Normal View History

2016-03-24 22:10:10 +00:00
<?php
2023-04-01 17:30:04 +00:00
declare(strict_types=1);
2016-03-24 22:10:10 +00:00
2023-04-01 17:30:04 +00:00
namespace App\Controller;
2016-03-24 22:10:10 +00:00
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
2023-04-01 17:30:04 +00:00
use App\Entity\Blog\Post;
use App\Repository\Blog\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2016-03-24 22:10:10 +00:00
use Symfony\Component\HttpFoundation\Response;
2017-11-05 02:03:26 +00:00
class PostController extends AbstractController
2016-03-24 22:10:10 +00:00
{
/**
* @ParamConverter("post", class="SkobkinPointToolsBundle:Blogs\Post")
*/
public function showAction(Post $post, PostRepository $postRepository): Response
2016-03-24 22:10:10 +00:00
{
if ((!$post->getAuthor()->isPublic()) || $post->getAuthor()->isWhitelistOnly()) {
/**
* Throwing 404 instead of 403 because of
* @see \Symfony\Component\Security\Http\Firewall\ExceptionListener::handleAccessDeniedException()
* starts to replace 403 by 401 exceptions for anonymous users and tries to authenticate them.
*/
throw $this->createNotFoundException('Author\'s blog is private.');
//throw $this->createAccessDeniedException('Author\'s blog is private.');
}
2016-03-24 22:10:10 +00:00
return $this->render('SkobkinPointToolsBundle:Post:show.html.twig', [
'post' => $postRepository->getPostWithComments($post->getId()),
2016-03-24 22:10:10 +00:00
]);
}
}