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")
|
|
|
|
*/
|
2017-11-05 01:42:08 +00:00
|
|
|
public function showAction(Post $post, PostRepository $postRepository): Response
|
2016-03-24 22:10:10 +00:00
|
|
|
{
|
2019-04-03 15:07:47 +00:00
|
|
|
if ((!$post->getAuthor()->isPublic()) || $post->getAuthor()->isWhitelistOnly()) {
|
2019-04-03 17:34:16 +00:00
|
|
|
/**
|
|
|
|
* 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.');
|
2019-04-03 15:07:47 +00:00
|
|
|
}
|
|
|
|
|
2016-03-24 22:10:10 +00:00
|
|
|
return $this->render('SkobkinPointToolsBundle:Post:show.html.twig', [
|
2017-11-05 01:42:08 +00:00
|
|
|
'post' => $postRepository->getPostWithComments($post->getId()),
|
2016-03-24 22:10:10 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|