Skip to content

Commit 9d19379

Browse files
author
Leny BERNARD
committed
Merge pull request #369 from gregumo/master
Remove Template Mapper and reorganize layouts paths
2 parents cc5db76 + 0d74d3a commit 9d19379

File tree

43 files changed

+148
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+148
-274
lines changed

Bundle/BlogBundle/Controller/ArticleController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function createAction(Blog $blog)
8383
[
8484
'success' => false,
8585
'message' => $formErrorHelper->getRecursiveReadableErrors($form),
86-
'html' => $this->container->get('victoire_templating')->render(
86+
'html' => $this->container->get('templating')->render(
8787
'VictoireBlogBundle:Article:new.html.twig',
8888
[
8989
'form' => $form->createView(),
@@ -115,7 +115,7 @@ public function newBlogArticleAction(Blog $blog)
115115

116116
return new JsonResponse(
117117
[
118-
'html' => $this->container->get('victoire_templating')->render(
118+
'html' => $this->container->get('templating')->render(
119119
'VictoireBlogBundle:Article:new.html.twig',
120120
['form' => $form->createView(), 'blogId' => $blog->getId()]
121121
),
@@ -186,7 +186,7 @@ public function settingsAction(Request $request, Article $article)
186186

187187
$response = [
188188
'success' => !$form->isSubmitted(),
189-
'html' => $this->get('victoire_templating')->render($template, [
189+
'html' => $this->get('templating')->render($template, [
190190
'action' => $this->generateUrl('victoire_blog_article_settings', [
191191
'id' => $article->getId(),
192192
]),

Bundle/BlogBundle/Controller/BlogController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function indexAction(Request $request, $blogId = null, $tab = 'articles')
8282

8383
return new JsonResponse(
8484
[
85-
'html' => $this->container->get('victoire_templating')->render(
85+
'html' => $this->container->get('templating')->render(
8686
$template,
8787
[
8888
'blog' => $blog,
@@ -163,7 +163,7 @@ public function settingsAction(Request $request, BasePage $blog)
163163
//we display the form
164164
$errors = $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form);
165165
if ($errors != '') {
166-
return new JsonResponse(['html' => $this->container->get('victoire_templating')->render(
166+
return new JsonResponse(['html' => $this->container->get('templating')->render(
167167
$this->getBaseTemplatePath().':Tabs/_settings.html.twig',
168168
[
169169
'blog' => $blog,
@@ -176,7 +176,7 @@ public function settingsAction(Request $request, BasePage $blog)
176176
);
177177
}
178178

179-
return new Response($this->container->get('victoire_templating')->render(
179+
return new Response($this->container->get('templating')->render(
180180
$this->getBaseTemplatePath().':Tabs/_settings.html.twig',
181181
[
182182
'blog' => $blog,
@@ -223,7 +223,7 @@ public function categoryAction(Request $request, BasePage $blog)
223223
//we display the form
224224
$errors = $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form);
225225
if ($errors != '') {
226-
return new JsonResponse(['html' => $this->container->get('victoire_templating')->render(
226+
return new JsonResponse(['html' => $this->container->get('templating')->render(
227227
$this->getBaseTemplatePath().':Tabs/_category.html.twig',
228228
[
229229
'blog' => $blog,
@@ -236,7 +236,7 @@ public function categoryAction(Request $request, BasePage $blog)
236236
);
237237
}
238238

239-
return new Response($this->container->get('victoire_templating')->render(
239+
return new Response($this->container->get('templating')->render(
240240
$this->getBaseTemplatePath().':Tabs/_category.html.twig',
241241
[
242242
'blog' => $blog,
@@ -259,7 +259,7 @@ public function categoryAction(Request $request, BasePage $blog)
259259
*/
260260
public function articlesAction(Request $request, BasePage $blog)
261261
{
262-
return new Response($this->container->get('victoire_templating')->render(
262+
return new Response($this->container->get('templating')->render(
263263
$this->getBaseTemplatePath().':Tabs/_articles.html.twig',
264264
[
265265
'blog' => $blog,

Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function indexAction()
5656
}
5757

5858
return new JsonResponse([
59-
'html' => $this->container->get('victoire_templating')->render(
59+
'html' => $this->container->get('templating')->render(
6060
'VictoireBusinessPageBundle:BusinessEntity:index.html.twig',
6161
[
6262
'businessEntities' => $businessEntities,
@@ -197,7 +197,7 @@ public function newAction($id)
197197
];
198198

199199
return new JsonResponse([
200-
'html' => $this->container->get('victoire_templating')->render(
200+
'html' => $this->container->get('templating')->render(
201201
'VictoireBusinessPageBundle:BusinessTemplate:new.html.twig',
202202
$parameters
203203
),
@@ -240,7 +240,7 @@ public function editAction(View $view)
240240
];
241241

242242
return new JsonResponse([
243-
'html' => $this->container->get('victoire_templating')->render(
243+
'html' => $this->container->get('templating')->render(
244244
'VictoireBusinessPageBundle:BusinessTemplate:edit.html.twig',
245245
$parameters
246246
),

Bundle/CoreBundle/Builder/ViewCssBuilder.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
namespace Victoire\Bundle\CoreBundle\Builder;
44

5+
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
6+
use Symfony\Component\DependencyInjection\Container;
57
use Victoire\Bundle\CoreBundle\Entity\View;
6-
use Victoire\Bundle\CoreBundle\Template\TemplateMapper;
78
use Victoire\Bundle\WidgetBundle\Renderer\WidgetRenderer;
89

910
/**
1011
* View CSS Builder
1112
* ref: victoire_core.view_css_builder.
12-
*
13-
* @property templating
1413
*/
1514
class ViewCssBuilder
1615
{
17-
protected $templating;
16+
protected $container;
1817
protected $victoireTwigResponsive;
1918
private $widgetRenderer;
2019
private $webDir;
@@ -23,17 +22,17 @@ class ViewCssBuilder
2322
/**
2423
* Construct.
2524
*
26-
* @param TemplateMapper $templating
27-
* @param $victoireTwigResponsive
28-
* @param $kernelRootDir
25+
* @param EngineInterface $templating
26+
* @param $victoireTwigResponsive
27+
* @param $kernelRootDir
2928
*
3029
* @internal param WidgetRenderer $widgetRenderer
3130
*/
32-
public function __construct(TemplateMapper $templating, $victoireTwigResponsive, $kernelRootDir)
31+
public function __construct(Container $container, $victoireTwigResponsive, $kernelRootDir)
3332
{
3433
$this->webDir = '/view-css';
3534
$this->viewCssDir = $kernelRootDir.'/../web'.$this->webDir;
36-
$this->templating = $templating;
35+
$this->container = $container;
3736
$this->victoireTwigResponsive = $victoireTwigResponsive;
3837
}
3938

@@ -61,7 +60,7 @@ public function generateViewCss(View $view, array $widgets)
6160
$css = '';
6261

6362
foreach ($widgets as $widget) {
64-
$style = $this->templating->render(
63+
$style = $this->container->get('templating')->render(
6564
'VictoireCoreBundle:Widget:style/style.html.twig',
6665
[
6766
'widget' => $widget,

Bundle/CoreBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,9 @@ public function getConfigTreeBuilder()
4141
->treatNullLike([])
4242
->end()
4343
->end()
44-
->children()
45-
->variableNode('applicative_bundle')
46-
->defaultNull()
47-
->end()
48-
->end()
4944
->children()
5045
->variableNode('templates')
51-
->defaultValue(['layout' => 'VictoireCoreBundle::layout.html.twig'])
46+
->defaultValue(['layout' => 'VictoireCoreBundle:Layout:layout.html.twig'])
5247
->end()
5348
->end()
5449
->children()

Bundle/CoreBundle/DependencyInjection/VictoireCoreExtension.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ public function load(array $configs, ContainerBuilder $container)
4444
$container->setParameter(
4545
'victoire_core.business_entity_debug', $config['business_entity_debug']
4646
);
47-
$container->setParameter(
48-
'victoire_core.applicative_bundle', $config['applicative_bundle']
49-
);
5047
if (array_key_exists('templates', $config)) {
5148
$container->setParameter(
5249
'victoire_core.templates', $config['templates']

Bundle/CoreBundle/Entity/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ public function removeWidgetMap(WidgetMap $widgetMap)
688688
public function getWidgetsIds()
689689
{
690690
$widgetIds = [];
691-
foreach($this->getBuiltWidgetMap() as $slot => $_widgetMaps) {
691+
foreach ($this->getBuiltWidgetMap() as $slot => $_widgetMaps) {
692692
foreach ($_widgetMaps as $widgetMap) {
693693
$widgetIds[] = $widgetMap->getWidget()->getId();
694694
}

Bundle/CoreBundle/Handler/WidgetExceptionHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Victoire\Bundle\CoreBundle\Handler;
44

5+
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
56
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
67
use Symfony\Bundle\TwigBundle\TwigEngine;
78
use Symfony\Component\Debug\Exception\FlattenException;
89
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
9-
use Victoire\Bundle\CoreBundle\Template\TemplateMapper;
1010

1111
/**
1212
* ref: victoire_core.widget_exception_handler.
@@ -24,9 +24,9 @@ class WidgetExceptionHandler
2424
* @param SecurityContext $authorizationChecker
2525
* @param TwigEngine $twig
2626
* @param bool $debug The debug variable environment
27-
* @param TemplateMapper $templating The victoire templating
27+
* @param EngineInterface $templating
2828
*/
29-
public function __construct(AuthorizationChecker $authorizationChecker, $twig, $debug, TemplateMapper $templating)
29+
public function __construct(AuthorizationChecker $authorizationChecker, $twig, $debug, EngineInterface $templating)
3030
{
3131
$this->authorizationChecker = $authorizationChecker;
3232
$this->twig = $twig;

Bundle/CoreBundle/Resources/config/services.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,11 @@ services:
6363
tags:
6464
- { name: kernel.event_listener, event: kernel.controller, method: preExecuteAutorun }
6565

66-
# ================== Template ================== #
67-
victoire_core.template_mapper:
68-
class: Victoire\Bundle\CoreBundle\Template\TemplateMapper
69-
arguments: ["@service_container"]
70-
71-
victoire_templating:
72-
alias: victoire_core.template_mapper
73-
7466
# ================== Twig ================== #
7567
victoire_core.twig.cms_extension:
7668
class: Victoire\Bundle\CoreBundle\Twig\Extension\CmsExtension
7769
arguments:
7870
- "@Victoire_widget.widget_renderer"
79-
- "@victoire_templating"
8071
- "@security.authorization_checker"
8172
- "@victoire_core.widget_exception_handler"
8273
- "@victoire_core.current_view"
@@ -88,7 +79,6 @@ services:
8879
victoire_core.twig.globals_extension:
8980
class: Victoire\Bundle\CoreBundle\Twig\Extension\GlobalsExtension
9081
arguments:
91-
- "@victoire_templating"
9282
- "@session"
9383
tags:
9484
- { name: twig.extension }
@@ -165,7 +155,7 @@ services:
165155
- "@security.authorization_checker"
166156
- "@twig"
167157
- "%kernel.debug%"
168-
- "@victoire_templating"
158+
- "@templating"
169159

170160
# ================== View ================== #
171161

@@ -180,7 +170,7 @@ services:
180170
victoire_core.view_css_builder:
181171
class: Victoire\Bundle\CoreBundle\Builder\ViewCssBuilder
182172
arguments:
183-
- @victoire_templating
173+
- @service_container
184174
- %victoire_twig.responsive%
185175
- '%kernel.root_dir%'
186176

Bundle/CoreBundle/Resources/doc/SETUP.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ Follow the instructions on [victoire demo Readme](https://github.com/Victoire/de
6363
```yml
6464
victoire_core:
6565
user_class: Victoire\Bundle\UserBundle\Entity\User
66-
applicative_bundle: AppBundle #Optional
6766
templates:
6867
layout: "::layout.html.twig"
6968
layouts:

Bundle/CoreBundle/Resources/views/ajaxModalLayout.html.twig renamed to Bundle/CoreBundle/Resources/views/Layout/ajaxModalLayout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends 'VictoireCoreBundle::layout.html.twig' %}
1+
{% extends 'VictoireCoreBundle:Layout:layout.html.twig' %}
22

33
{% trans_default_domain "victoire" %}
44

Bundle/CoreBundle/Resources/views/backendLayout.html.twig renamed to Bundle/CoreBundle/Resources/views/Layout/backendLayout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends 'VictoireCoreBundle::layout.html.twig' %}
1+
{% extends 'VictoireCoreBundle:Layout:layout.html.twig' %}
22
{% trans_default_domain "victoire" %}
33
{% block meta %}<title>Backend</title>{% endblock meta %}
44
{% block container_attributes %}{{ parent() }} role="victoire-backend"{% endblock container_attributes %}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{% trans_default_domain "victoire" %}
2+
<!DOCTYPE html>
3+
<html {% block html_attr %}{% endblock html_attr %}>
4+
<head>
5+
{% block head %}
6+
{% block meta %}{% endblock meta %}
7+
{% block head_script %}{% endblock head_script %}
8+
{% block head_style %}{% endblock head_style %}
9+
{% block head_icons %}{% endblock head_icons %}
10+
{% endblock head %}
11+
</head>
12+
<body {% block container_attributes %}{% endblock container_attributes %} class="{% block container_class %}{% endblock container_class %}" {% block container_attr %}{% endblock container_attr %}>
13+
{% block body %}{% endblock body %}
14+
{% block foot_script %}{% endblock foot_script %}
15+
{% block foot_script_additional %}{% endblock foot_script_additional %}
16+
{% block javascript %}{% endblock javascript %}
17+
</body>
18+
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{% extends 'VictoireCoreBundle:Layout:layout.html.twig' %}
2+
3+
{% trans_default_domain "victoire" %}
4+
5+
{% block head_script %}
6+
<!-- HEAD_SCRIPT -->
7+
{% if is_granted('ROLE_VICTOIRE') %}
8+
{% javascripts injector="victoire-head, modernizr" %}
9+
<script type="text/javascript" src="{{ asset_url }}"></script>
10+
{% endjavascripts %}
11+
{% endif %}
12+
<!-- END HEAD_SCRIPT -->
13+
14+
{{ parent() }}
15+
{% endblock head_script %}
16+
17+
{% block body %}
18+
{% if is_granted('ROLE_VICTOIRE') %}
19+
{% include 'VictoireCoreBundle:Menu:admin_navbar.html.twig' %}
20+
{% endif %}
21+
22+
{% block header %}
23+
{% endblock %}
24+
25+
{% block content %}
26+
{% endblock content %}
27+
28+
{% block footer %}
29+
{% endblock %}
30+
31+
{% endblock body %}
32+
33+
{% block foot_script_additional %}
34+
{% endblock foot_script_additional %}

Tests/Functionnal/app/Resources/views/layout/fullWidth.html.twig renamed to Bundle/CoreBundle/Resources/views/Layout/fullWidth.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends '::frontLayout.html.twig' %}
1+
{% extends 'VictoireCoreBundle:Layout:frontLayout.html.twig' %}
22

33
{% block content %}
44
{{ cms_slot_widgets('content') }}

Bundle/CoreBundle/Resources/views/layout.html.twig renamed to Bundle/CoreBundle/Resources/views/Layout/layout.html.twig

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
{% extends 'VictoireCoreBundle::base.html.twig' %}
1+
{% extends 'VictoireCoreBundle:Layout:base.html.twig' %}
22

33
{% trans_default_domain "victoire" %}
44

5-
{% block container_attributes %}{{ parent() }} {% if app.session.get('victoire.edit_mode') %}role="{{ app.session.get('victoire.edit_mode') }}"{% endif %}{% endblock container_attributes %}
6-
7-
{% block container_class %}{% endblock container_class %}
5+
{% block html_attr %}ng-app="ngApp" lang="{{ app.request.locale|split('_')[0] }}"{% endblock html_attr %}
86
{% block title %}Victoire DCMS{% endblock title %}
7+
{% block meta %}{% include 'VictoireSeoBundle::_meta.html.twig' %}{% endblock meta %}
8+
{% block head_icons %}<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />{% endblock head_icons %}
99

1010
{% block head_script %}
1111
<!-- HEAD_SCRIPT -->
@@ -36,12 +36,16 @@
3636
<!-- END HEAD_STYLE -->
3737

3838
{% endblock head_style %}
39+
40+
{% block container_attributes %}{{ parent() }} {% if app.session.get('victoire.edit_mode') %}role="{{ app.session.get('victoire.edit_mode') }}"{% endif %}{% endblock container_attributes %}
41+
{% block container_class %}{% endblock container_class %}
42+
{% block container_attr %}ng-controller="PageController as pageCtrl" ng-init="init({% if view is defined %}'{{ view.cssHash }}'{% endif %})"{% endblock %}
3943
{% block body %}
40-
{% if is_granted('ROLE_VICTOIRE') %}
41-
{% include 'VictoireCoreBundle:Menu:admin_navbar.html.twig' %}
42-
{% endif %}
43-
{% block content %}
44-
{% endblock content %}
44+
{{ cms_page_css() }}
45+
{% if is_granted('ROLE_VICTOIRE') %}
46+
{% include 'VictoireCoreBundle:Menu:admin_navbar.html.twig' %}
47+
{% endif %}
48+
{% block content %}{% endblock content %}
4549
{% endblock body %}
4650

4751
{% block foot_script %}
@@ -95,4 +99,7 @@
9599

96100

97101
{% block foot_script_additional %}
102+
{% if is_granted('ROLE_VICTOIRE') %}
103+
{% include 'VictoireCoreBundle::_userVoice.html.twig' %}
104+
{% endif %}
98105
{% endblock foot_script_additional %}

0 commit comments

Comments
 (0)