|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Alpixel\Bundle\CMSBundle\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use Alpixel\Bundle\CMSBundle\Entity\Node; |
|
6
|
|
|
use Alpixel\Bundle\SEOBundle\Annotation\MetaTag; |
|
7
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
|
8
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; |
|
9
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
|
10
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
11
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
12
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
13
|
|
|
|
|
14
|
|
|
class FrontNodeController extends Controller |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @Route("/page/{slug}", name="alpixel_cms") |
|
18
|
|
|
* @MetaTag("node", providerClass="Alpixel\Bundle\CMSBundle\Entity\Node", title="Page de contenu") |
|
19
|
|
|
* @ParamConverter("node", options={"mapping" : {"slug": "slug"}}) |
|
20
|
|
|
* @Method("GET") |
|
21
|
|
|
*/ |
|
22
|
|
|
public function dispatchAction(Request $request, Node $node) |
|
23
|
|
|
{ |
|
24
|
|
|
$object = $this->get('cms.helper')->getNodeElementEntityFromNode($node); |
|
25
|
|
|
|
|
26
|
|
|
if ($object !== null && $object->getNode()->getPublished()) { |
|
27
|
|
|
if (stripos($request->getLocale(), $object->getNode()->getLocale()) !== false) { |
|
28
|
|
|
$contentType = $this->get('cms.helper')->getContentTypeFromNodeElementClass($object); |
|
29
|
|
|
return $this->forward($contentType['controller'], [ |
|
30
|
|
|
'_route' => $this->getRequest()->attributes->get('_route'), |
|
|
|
|
|
|
31
|
|
|
'_route_params' => $this->getRequest()->attributes->get('_route_params'), |
|
|
|
|
|
|
32
|
|
|
'object' => $object, |
|
33
|
|
|
]); |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
throw $this->createNotFoundException(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function displayNodeAdminBarAction(Node $node) |
|
41
|
|
|
{ |
|
42
|
|
|
$canEdit = $this->get('request')->cookies->get('can_edit'); |
|
43
|
|
|
|
|
44
|
|
|
if ($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) { |
|
45
|
|
|
return $this->render('CMSBundle:admin:blocks/admin_bar_page.html.twig', [ |
|
46
|
|
|
'link' => $this->generateUrl('admin_alpixel_cms_node_editContent', ['id' => $node->getId()]), |
|
47
|
|
|
]); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return new Response(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function displayCustomAdminBarAction($link) |
|
54
|
|
|
{ |
|
55
|
|
|
$canEdit = $this->get('request')->cookies->get('can_edit'); |
|
56
|
|
|
|
|
57
|
|
|
if ($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) { |
|
58
|
|
|
return $this->render('CMSBundle:admin:blocks/admin_bar_page.html.twig', [ |
|
59
|
|
|
'link' => $link, |
|
60
|
|
|
]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return new Response(); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.