Skip to content
This repository was archived by the owner on Aug 8, 2021. It is now read-only.

Commit cbe3783

Browse files
committed
Deprecation in PageController resolved, cms_menu accepts now templates
1 parent 252540e commit cbe3783

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
v1.0.1-alpha
2+
- getEntityManager()-deprecation in PageController.php resolved
3+
- Twig-Funtion cms_menu() allows now a template for the menu (example: cms_menu('some-slug', 'AppBundle:menus:main_menu.html.twig'))

Controller/PageController.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Devtronic\CmsBundle\Controller;
44

5-
use Doctrine\ORM\EntityNotFoundException;
65
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
76
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
87
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
@@ -16,13 +15,11 @@ class PageController extends Controller
1615
*/
1716
public function pageAction($slug)
1817
{
19-
$em = $this->getDoctrine()->getEntityManager();
18+
$em = $this->getDoctrine()->getManager();
2019
$repo = $em->getRepository('CmsBundle:Page');
2120

2221
$page = $repo->findOneBySlug($slug);
2322

24-
25-
2623
return array('page' => $page);
2724
}
2825

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ devtronic_cms_bundle:
5454
```twig
5555
{# anything.html.twig #}
5656
{{ cms_menu("MENU SLUG GOES HERE") | raw }}
57+
58+
{# or with a custom Menu Template #}
59+
{{ cms_menu("MENU SLUG GOES HERE", "AnyBundle:Path:menu_template.html.twig") | raw }}
5760
```
5861
### Templates
5962
#### Menu Template

Twig/CmsTwigExtension.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ public function getFunctions()
2828
);
2929
}
3030

31-
public function menu(\Twig_Environment $twig, $menuSlug)
31+
/**
32+
* @param string $menuSlug Slug of the menu
33+
* @param \Twig_Template $menuTemplate
34+
* @return string The rendered menu
35+
*/
36+
public function menu(\Twig_Environment $twig, $menuSlug, $menuTemplate = 'CmsBundle::menu.html.twig')
3237
{
3338
$repo = $this->em->getRepository('CmsBundle:Menu');
3439
$menu = $repo->findOneBySlug($menuSlug);
35-
return $twig->render('CmsBundle::menu.html.twig', array('menu' => $menu));
40+
return $twig->render($menuTemplate, array('menu' => $menu));
3641
}
3742

3843
/**

0 commit comments

Comments
 (0)