2012-07-31 07:46:25 +00:00
|
|
|
<?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;
|
2012-08-09 15:54:55 +00:00
|
|
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
2012-07-31 07:46:25 +00:00
|
|
|
|
|
|
|
use KekRozsak\FrontBundle\Entity\Article;
|
|
|
|
|
|
|
|
class ArticleController extends Controller
|
|
|
|
{
|
2012-08-16 13:52:41 +00:00
|
|
|
/**
|
|
|
|
* @Route("/cikk/{slug}", name="KekRozsakFrontBundle_articleView")
|
|
|
|
* @Template()
|
|
|
|
* @ParamConverter("article")
|
|
|
|
*
|
|
|
|
* @param KekRozsak\FrontBundle\Entity\Article $article
|
|
|
|
*/
|
|
|
|
public function viewAction(Article $article)
|
|
|
|
{
|
|
|
|
$scontext = $this->get('security.context');
|
|
|
|
if (
|
|
|
|
(
|
|
|
|
!is_object($scontext->getToken())
|
|
|
|
|| !is_object($scontext->getToken()->getUser())
|
|
|
|
)
|
|
|
|
&& !$article->isPublic()
|
|
|
|
) {
|
|
|
|
throw new AccessDeniedException('A cikk megtekintéséhez be kell jelentkezned!');
|
|
|
|
}
|
2012-08-09 07:31:44 +00:00
|
|
|
|
2012-08-16 13:52:41 +00:00
|
|
|
return array(
|
|
|
|
'article' => $article,
|
|
|
|
);
|
|
|
|
}
|
2012-07-31 07:46:25 +00:00
|
|
|
}
|