@@ -6,8 +6,6 @@ |
||
6 | 6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
7 | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; |
8 | 8 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
9 | -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
|
10 | -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
|
11 | 9 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
12 | 10 | use Symfony\Component\HttpFoundation\Response; |
13 | 11 |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | |
30 | 30 | foreach ($meta as $m) { |
31 | 31 | $relations = $m->getAssociationMappings(); |
32 | - if(array_key_exists('node', $relations) && $relations['node']['targetEntity'] == 'Alpixel\Bundle\CMSBundle\Entity\Node') { |
|
32 | + if (array_key_exists('node', $relations) && $relations['node']['targetEntity'] == 'Alpixel\Bundle\CMSBundle\Entity\Node') { |
|
33 | 33 | $entities[] = $m; |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | - foreach($entities as $entity) { |
|
37 | + foreach ($entities as $entity) { |
|
38 | 38 | $object = $entityManager |
39 | 39 | ->getRepository($entity->getName()) |
40 | 40 | ->findOneByNode($node) |
41 | 41 | ; |
42 | 42 | |
43 | - if($object !== null && $object->getNode()->getPublished()) { |
|
43 | + if ($object !== null && $object->getNode()->getPublished()) { |
|
44 | 44 | $contentTypes = $this->container->getParameter('cms.content_types'); |
45 | - foreach($contentTypes as $contentType) { |
|
46 | - if($contentType['class'] == get_class($object)) { |
|
45 | + foreach ($contentTypes as $contentType) { |
|
46 | + if ($contentType['class'] == get_class($object)) { |
|
47 | 47 | return $this->forward($contentType['controller'], array( |
48 | 48 | '_route' => $this->getRequest()->attributes->get('_route'), |
49 | 49 | '_route_params' => $this->getRequest()->attributes->get('_route_params'), |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function displayNodeAdminBarAction(Node $node) { |
60 | 60 | $canEdit = $this->get('request')->cookies->get('can_edit'); |
61 | 61 | |
62 | - if($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) { |
|
62 | + if ($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) { |
|
63 | 63 | return $this->render('CMSBundle:admin:blocks/admin_bar_page.html.twig', array( |
64 | 64 | 'link' => $this->generateUrl('admin_alpixel_cms_node_editContent', array('id' => $node->getId())) |
65 | 65 | )); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function displayCustomAdminBarAction($link) { |
71 | 71 | $canEdit = $this->get('request')->cookies->get('can_edit'); |
72 | 72 | |
73 | - if($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) { |
|
73 | + if ($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) { |
|
74 | 74 | return $this->render('CMSBundle:admin:blocks/admin_bar_page.html.twig', array( |
75 | 75 | 'link' => $link |
76 | 76 | )); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function displayBlock(\Twig_Environment $twig, $blockName) |
42 | 42 | { |
43 | - if(array_key_exists($blockName, $this->blocks)) { |
|
43 | + if (array_key_exists($blockName, $this->blocks)) { |
|
44 | 44 | $blockConf = $this->blocks[$blockName]; |
45 | 45 | |
46 | 46 | $block = $this |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | array() |
53 | 53 | ); |
54 | 54 | |
55 | - if($block === null) { |
|
55 | + if ($block === null) { |
|
56 | 56 | $block = new Block; |
57 | 57 | $block->setName($blockConf['title']); |
58 | 58 | $block->setContent($blockConf['default']); |
59 | 59 | $block->setSlug($blockName); |
60 | 60 | |
61 | - if(!empty($blockConf['class']) && $blockConf['class'] !== null && $blockConf['class'] != "Alpixel\Bundle\CMSBundle\Entity\Block") { |
|
61 | + if (!empty($blockConf['class']) && $blockConf['class'] !== null && $blockConf['class'] != "Alpixel\Bundle\CMSBundle\Entity\Block") { |
|
62 | 62 | $subBlock = new $blockConf['class']; |
63 | 63 | $subBlock->setBlock($block); |
64 | 64 | $this->doctrine->getManager()->persist($subBlock); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->doctrine->getManager()->flush(); |
69 | 69 | } |
70 | 70 | |
71 | - if(!empty($blockConf['service'])) { |
|
71 | + if (!empty($blockConf['service'])) { |
|
72 | 72 | $controller = $this->container->get($blockConf['service']); |
73 | 73 | return $controller->renderAction(); |
74 | 74 | } else { |
@@ -11,7 +11,7 @@ |
||
11 | 11 | { |
12 | 12 | protected function configureFormFields(FormMapper $formMapper) |
13 | 13 | { |
14 | - $container = $this->getConfigurationPool()->getContainer(); |
|
14 | + $container = $this->getConfigurationPool()->getContainer(); |
|
15 | 15 | |
16 | 16 | $formMapper |
17 | 17 | ->add('node.title', null, array( |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | class AdminNode extends Admin |
11 | 11 | { |
12 | 12 | |
13 | - protected $datagridValues = array( |
|
13 | + protected $datagridValues = array( |
|
14 | 14 | '_page' => 1, |
15 | 15 | '_sort_order' => 'DESC', |
16 | 16 | ); |
17 | 17 | |
18 | 18 | protected function configureRoutes(RouteCollection $collection) |
19 | 19 | { |
20 | - $collection->add('editContent', $this->getRouterIdParameter() . '/edit/node'); |
|
20 | + $collection->add('editContent', $this->getRouterIdParameter().'/edit/node'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | )) |
45 | 45 | ->add('node', 'doctrine_orm_callback', array( |
46 | 46 | 'label' => 'Type de contenu', |
47 | - 'callback' => function($queryBuilder, $alias, $field, $value){ |
|
48 | - if(!$value['value']) { |
|
47 | + 'callback' => function($queryBuilder, $alias, $field, $value) { |
|
48 | + if (!$value['value']) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 |
@@ -10,14 +10,14 @@ |
||
10 | 10 | |
11 | 11 | class AdminBlock extends Admin |
12 | 12 | { |
13 | - protected $datagridValues = array( |
|
13 | + protected $datagridValues = array( |
|
14 | 14 | '_page' => 1, |
15 | 15 | '_sort_order' => 'DESC', |
16 | 16 | ); |
17 | 17 | |
18 | 18 | protected function configureRoutes(RouteCollection $collection) |
19 | 19 | { |
20 | - $collection->add('editContent', $this->getRouterIdParameter() . '/edit/block'); |
|
20 | + $collection->add('editContent', $this->getRouterIdParameter().'/edit/block'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -19,32 +19,32 @@ |
||
19 | 19 | $configuration = new Configuration(); |
20 | 20 | $config = $this->processConfiguration($configuration, $configs); |
21 | 21 | |
22 | - foreach($config['content_types'] as $name=>$contentType) { |
|
22 | + foreach ($config['content_types'] as $name=>$contentType) { |
|
23 | 23 | |
24 | - if(empty($contentType['title'])) |
|
24 | + if (empty($contentType['title'])) |
|
25 | 25 | throw new InvalidConfigurationException('Content type '.$name.' shoud have a title'); |
26 | 26 | |
27 | - if(empty($contentType['description'])) |
|
27 | + if (empty($contentType['description'])) |
|
28 | 28 | throw new InvalidConfigurationException('Content type '.$name.' shoud have a description'); |
29 | 29 | |
30 | - if(!isset($contentType['class']) || empty($contentType['class']) || !class_exists($contentType['class'])) |
|
30 | + if (!isset($contentType['class']) || empty($contentType['class']) || !class_exists($contentType['class'])) |
|
31 | 31 | throw new InvalidConfigurationException('CMS '.$contentType['class'].' can\'t be found'); |
32 | 32 | |
33 | - if(empty($contentType['controller'])) |
|
33 | + if (empty($contentType['controller'])) |
|
34 | 34 | throw new InvalidConfigurationException('CMS '.$contentType['controller'].' can\'t be found'); |
35 | 35 | |
36 | 36 | $container->setParameter('cms.content_types', $config['content_types']); |
37 | 37 | } |
38 | 38 | |
39 | - foreach($config['blocks'] as $name=>$contentType) { |
|
39 | + foreach ($config['blocks'] as $name=>$contentType) { |
|
40 | 40 | |
41 | - if(empty($contentType['title'])) |
|
41 | + if (empty($contentType['title'])) |
|
42 | 42 | throw new InvalidConfigurationException('Block '.$name.' shoud have a title'); |
43 | 43 | |
44 | - if( (!isset($contentType['class']) || empty($contentType['class'])) && class_exists($this->_blockDefaultClass) ) |
|
44 | + if ((!isset($contentType['class']) || empty($contentType['class'])) && class_exists($this->_blockDefaultClass)) |
|
45 | 45 | $config['blocks'][$name]['class'] = $this->_blockDefaultClass; |
46 | 46 | |
47 | - if(isset($contentType['class']) && !class_exists($contentType['class'])) |
|
47 | + if (isset($contentType['class']) && !class_exists($contentType['class'])) |
|
48 | 48 | throw new InvalidConfigurationException('Block '.$contentType['class'].' can\'t be found'); |
49 | 49 | |
50 | 50 | $container->setParameter('cms.blocks', $config['blocks']); |
@@ -21,31 +21,38 @@ |
||
21 | 21 | |
22 | 22 | foreach($config['content_types'] as $name=>$contentType) { |
23 | 23 | |
24 | - if(empty($contentType['title'])) |
|
25 | - throw new InvalidConfigurationException('Content type '.$name.' shoud have a title'); |
|
24 | + if(empty($contentType['title'])) { |
|
25 | + throw new InvalidConfigurationException('Content type '.$name.' shoud have a title'); |
|
26 | + } |
|
26 | 27 | |
27 | - if(empty($contentType['description'])) |
|
28 | - throw new InvalidConfigurationException('Content type '.$name.' shoud have a description'); |
|
28 | + if(empty($contentType['description'])) { |
|
29 | + throw new InvalidConfigurationException('Content type '.$name.' shoud have a description'); |
|
30 | + } |
|
29 | 31 | |
30 | - if(!isset($contentType['class']) || empty($contentType['class']) || !class_exists($contentType['class'])) |
|
31 | - throw new InvalidConfigurationException('CMS '.$contentType['class'].' can\'t be found'); |
|
32 | + if(!isset($contentType['class']) || empty($contentType['class']) || !class_exists($contentType['class'])) { |
|
33 | + throw new InvalidConfigurationException('CMS '.$contentType['class'].' can\'t be found'); |
|
34 | + } |
|
32 | 35 | |
33 | - if(empty($contentType['controller'])) |
|
34 | - throw new InvalidConfigurationException('CMS '.$contentType['controller'].' can\'t be found'); |
|
36 | + if(empty($contentType['controller'])) { |
|
37 | + throw new InvalidConfigurationException('CMS '.$contentType['controller'].' can\'t be found'); |
|
38 | + } |
|
35 | 39 | |
36 | 40 | $container->setParameter('cms.content_types', $config['content_types']); |
37 | 41 | } |
38 | 42 | |
39 | 43 | foreach($config['blocks'] as $name=>$contentType) { |
40 | 44 | |
41 | - if(empty($contentType['title'])) |
|
42 | - throw new InvalidConfigurationException('Block '.$name.' shoud have a title'); |
|
45 | + if(empty($contentType['title'])) { |
|
46 | + throw new InvalidConfigurationException('Block '.$name.' shoud have a title'); |
|
47 | + } |
|
43 | 48 | |
44 | - if( (!isset($contentType['class']) || empty($contentType['class'])) && class_exists($this->_blockDefaultClass) ) |
|
45 | - $config['blocks'][$name]['class'] = $this->_blockDefaultClass; |
|
49 | + if( (!isset($contentType['class']) || empty($contentType['class'])) && class_exists($this->_blockDefaultClass) ) { |
|
50 | + $config['blocks'][$name]['class'] = $this->_blockDefaultClass; |
|
51 | + } |
|
46 | 52 | |
47 | - if(isset($contentType['class']) && !class_exists($contentType['class'])) |
|
48 | - throw new InvalidConfigurationException('Block '.$contentType['class'].' can\'t be found'); |
|
53 | + if(isset($contentType['class']) && !class_exists($contentType['class'])) { |
|
54 | + throw new InvalidConfigurationException('Block '.$contentType['class'].' can\'t be found'); |
|
55 | + } |
|
49 | 56 | |
50 | 57 | $container->setParameter('cms.blocks', $config['blocks']); |
51 | 58 | } |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | $content = null; |
25 | 25 | $classPassed = array(); |
26 | 26 | $className = ''; |
27 | - foreach($this->getCMSParameter() as $key => $value) { |
|
28 | - if($this->_blockDefaultClass === $value['class'] || in_array($value['class'], $classPassed)) { |
|
27 | + foreach ($this->getCMSParameter() as $key => $value) { |
|
28 | + if ($this->_blockDefaultClass === $value['class'] || in_array($value['class'], $classPassed)) { |
|
29 | 29 | continue; |
30 | 30 | } |
31 | 31 | |
32 | 32 | $repository = $entityManager->getRepository($value['class']); |
33 | 33 | $content = $repository->findOneByBlock($object->getId()); |
34 | 34 | |
35 | - if($content !== null) { |
|
35 | + if ($content !== null) { |
|
36 | 36 | $className = $value['class']; |
37 | 37 | break; |
38 | 38 | } |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | $classPassed[] = $value['class']; |
41 | 41 | } |
42 | 42 | |
43 | - if($content === null) { |
|
43 | + if ($content === null) { |
|
44 | 44 | $repository = $entityManager->getRepository($this->_blockDefaultClass); |
45 | 45 | $content = $repository->findOneById($object); |
46 | 46 | $className = $this->_blockDefaultClass; |
47 | 47 | } |
48 | 48 | |
49 | - if($content !== null) { |
|
49 | + if ($content !== null) { |
|
50 | 50 | $instanceAdmin = $this->admin->getConfigurationPool()->getAdminByClass($className); |
51 | 51 | |
52 | - if($instanceAdmin !== null) { |
|
52 | + if ($instanceAdmin !== null) { |
|
53 | 53 | return $this->redirect($instanceAdmin->generateUrl('edit', array('id' => $content->getId()))); |
54 | 54 | } |
55 | 55 | } |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * Set instances of admin in $_cmsContentParameter |
83 | 83 | */ |
84 | 84 | protected function getInstancesAdmin() { |
85 | - foreach($this->getCMSParameter() as $key => $value) { |
|
86 | - if($this->checkRolesCMS($value)) { |
|
85 | + foreach ($this->getCMSParameter() as $key => $value) { |
|
86 | + if ($this->checkRolesCMS($value)) { |
|
87 | 87 | $instanceAdmin = $this->admin->getConfigurationPool()->getAdminByClass($value['class']); |
88 | - if($instanceAdmin !== null) { |
|
88 | + if ($instanceAdmin !== null) { |
|
89 | 89 | $this->_cmsContentParameter[$key]['admin'] = $instanceAdmin; |
90 | 90 | } |
91 | 91 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | throw new NotFoundHttpException(sprintf('unable to find user in %s file', __FILE__)); |
105 | 105 | } |
106 | 106 | |
107 | - if(!array_key_exists('role', $role) || in_array($user->getRoles()[0], $role['role'])) { |
|
107 | + if (!array_key_exists('role', $role) || in_array($user->getRoles()[0], $role['role'])) { |
|
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function getCMSParameter() |
120 | 120 | { |
121 | - if($this->_cmsContentParameter !== null) { |
|
121 | + if ($this->_cmsContentParameter !== null) { |
|
122 | 122 | return $this->_cmsContentParameter; |
123 | 123 | } |
124 | 124 |
@@ -17,25 +17,25 @@ discard block |
||
17 | 17 | throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id)); |
18 | 18 | } |
19 | 19 | |
20 | - if(!$this->container->hasParameter('cms.content_types')) { |
|
21 | - throw new NotFoundHttpException('cms.content_types parameters in ' . __FILE__ .' file at line ' . __LINE__ . ' in ' . __FUNCTION__ . ' method, has not been not found, maybe you must be configured cms.yml file'); |
|
20 | + if (!$this->container->hasParameter('cms.content_types')) { |
|
21 | + throw new NotFoundHttpException('cms.content_types parameters in '.__FILE__.' file at line '.__LINE__.' in '.__FUNCTION__.' method, has not been not found, maybe you must be configured cms.yml file'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | // Get admin class define in cms.yml |
25 | 25 | $cmsContentType = $this->container->getParameter('cms.content_types'); |
26 | 26 | $entityManager = $this->getDoctrine()->getManager(); |
27 | 27 | |
28 | - if(array_key_exists($object->getType(), $cmsContentType)) { |
|
28 | + if (array_key_exists($object->getType(), $cmsContentType)) { |
|
29 | 29 | $contentType = $cmsContentType[$object->getType()]; |
30 | 30 | |
31 | 31 | $content = $entityManager |
32 | 32 | ->getRepository($contentType['class']) |
33 | 33 | ->findOneByNode($object); |
34 | 34 | |
35 | - if($content !== null) { |
|
35 | + if ($content !== null) { |
|
36 | 36 | $instanceAdmin = $this->admin->getConfigurationPool()->getAdminByClass($contentType['class']); |
37 | 37 | |
38 | - if($instanceAdmin !== null) { |
|
38 | + if ($instanceAdmin !== null) { |
|
39 | 39 | return $this->redirect($instanceAdmin->generateUrl('edit', array('id' => $content->getId()))); |
40 | 40 | } |
41 | 41 | |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | $datagrid = $this->admin->getDatagrid(); |
54 | 54 | $formView = $datagrid->getForm()->createView(); |
55 | 55 | |
56 | - if(!$this->container->hasParameter('cms.content_types')) { |
|
57 | - throw $this->createNotFoundException('cms.content_types parameters in ' . __FILE__ .' file at line ' . __LINE__ . ' in ' . __FUNCTION__ . ' method, has not been not found, maybe you must be configured cms.yml file'); |
|
56 | + if (!$this->container->hasParameter('cms.content_types')) { |
|
57 | + throw $this->createNotFoundException('cms.content_types parameters in '.__FILE__.' file at line '.__LINE__.' in '.__FUNCTION__.' method, has not been not found, maybe you must be configured cms.yml file'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $cmsContentType = $this->container->getParameter('cms.content_types'); |
61 | 61 | |
62 | - foreach($cmsContentType as $key => $value) { |
|
63 | - if($this->checkRolesCMS($value)) { |
|
64 | - if($instanceAdmin = $this->admin->getConfigurationPool()->getAdminByClass($value['class'])) { |
|
62 | + foreach ($cmsContentType as $key => $value) { |
|
63 | + if ($this->checkRolesCMS($value)) { |
|
64 | + if ($instanceAdmin = $this->admin->getConfigurationPool()->getAdminByClass($value['class'])) { |
|
65 | 65 | $cmsContentType[$key]['admin'] = $instanceAdmin; |
66 | 66 | } |
67 | 67 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | $userRole = $user->getRoles()[0]; |
90 | 90 | |
91 | - if(!array_key_exists('role', $role) || in_array($userRole, $role['role'])) { |
|
91 | + if (!array_key_exists('role', $role) || in_array($userRole, $role['role'])) { |
|
92 | 92 | return true; |
93 | 93 | } |
94 | 94 |
@@ -9,25 +9,25 @@ |
||
9 | 9 | class LoginListener |
10 | 10 | { |
11 | 11 | |
12 | - private $securityContext; |
|
13 | - private $request; |
|
14 | - private $secret; |
|
12 | + private $securityContext; |
|
13 | + private $request; |
|
14 | + private $secret; |
|
15 | 15 | |
16 | - public function __construct(SecurityContext $securityContext, Request $request, $secret) { |
|
16 | + public function __construct(SecurityContext $securityContext, Request $request, $secret) { |
|
17 | 17 | $this->securityContext = $securityContext; |
18 | 18 | $this->request = $request; |
19 | 19 | $this->secret = $secret; |
20 | - } |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Do the magic. |
|
24 | - * |
|
25 | - * @param InteractiveLoginEvent $event |
|
26 | - */ |
|
27 | - public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) |
|
28 | - { |
|
22 | + /** |
|
23 | + * Do the magic. |
|
24 | + * |
|
25 | + * @param InteractiveLoginEvent $event |
|
26 | + */ |
|
27 | + public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) |
|
28 | + { |
|
29 | 29 | if ($this->securityContext->isGranted('ROLE_ADMIN')) { |
30 | - setcookie ("can_edit", hash('sha256', 'can_edit'.$this->secret), 0, '/'); |
|
30 | + setcookie ("can_edit", hash('sha256', 'can_edit'.$this->secret), 0, '/'); |
|
31 | + } |
|
31 | 32 | } |
32 | - } |
|
33 | 33 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) |
28 | 28 | { |
29 | 29 | if ($this->securityContext->isGranted('ROLE_ADMIN')) { |
30 | - setcookie ("can_edit", hash('sha256', 'can_edit'.$this->secret), 0, '/'); |
|
30 | + setcookie("can_edit", hash('sha256', 'can_edit'.$this->secret), 0, '/'); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |