kekrozsak/src/KekRozsak/FrontBundle/Controller/ArticleController.php
Polonkai Gergely 121f6a110c Article view is now security aware
ArticleController::viewAction is now aware of Article::public

Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
2012-08-09 09:31:44 +02:00

31 lines
909 B
PHP

<?php
namespace KekRozsak\FrontBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use KekRozsak\FrontBundle\Entity\Article;
class ArticleController extends Controller
{
/**
* @Route("/cikk/{slug}", name="KekRozsakFrontBundle_articleView")
* @Template()
* @ParamConverter("article")
*
* @param KekRozsak\FrontBundle\Entity\Article $article
*/
public function viewAction(Article $article)
{
if ((!is_object($this->_securityContext->getToken()) || !is_object($this->_securityContext->getToken()->getUser())) && !$article->isPublic())
throw new AccessDeniedException('A cikk megtekintéséhez be kell jelentkezned!');
return array(
'article' => $article,
);
}
}