Skip to content

Commit 9862577

Browse files
committed
bug #870 [make:crud] Fix templates path use in include (leblanc-simon)
This PR was merged into the 1.0-dev branch. Discussion ---------- [make:crud] Fix templates path use in include The maker CRUD allow to set a namespace in the controller name (example : `Admin\ArticleController`). In this case, maker create namespace and folders for the templates. ``` s.leblanc@cronos $ symfony console make:crud Article Choose a name for your controller class (e.g. ArticleController) [ArticleController]: > Admin\ArticleController created: src/Controller/Admin/ArticleController.php created: src/Form/ArticleType.php created: templates/admin/article/_delete_form.html.twig created: templates/admin/article/_form.html.twig created: templates/admin/article/edit.html.twig created: templates/admin/article/index.html.twig created: templates/admin/article/new.html.twig created: templates/admin/article/show.html.twig ``` The controller is OK, the render function is call with the good path : `admin/article/index.html.twig` But in the template, when we include the form or the delete form, the path is build with route name (`admin_article`) instead of path (`admin/article`) This path fix this issue Commits ------- 0ebb463 Fix templates path include for CRUD Maker
2 parents b33db86 + 0ebb463 commit 9862577

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/Maker/MakeCrud.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
193193
'entity_twig_var_singular' => $entityTwigVarSingular,
194194
'entity_identifier' => $entityDoctrineDetails->getIdentifier(),
195195
'route_name' => $routeName,
196+
'templates_path' => $templatesPath,
196197
],
197198
'index' => [
198199
'entity_class_name' => $entityClassDetails->getShortName(),
@@ -205,13 +206,15 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
205206
'new' => [
206207
'entity_class_name' => $entityClassDetails->getShortName(),
207208
'route_name' => $routeName,
209+
'templates_path' => $templatesPath,
208210
],
209211
'show' => [
210212
'entity_class_name' => $entityClassDetails->getShortName(),
211213
'entity_twig_var_singular' => $entityTwigVarSingular,
212214
'entity_identifier' => $entityDoctrineDetails->getIdentifier(),
213215
'entity_fields' => $entityDoctrineDetails->getDisplayFields(),
214216
'route_name' => $routeName,
217+
'templates_path' => $templatesPath,
215218
],
216219
];
217220

src/Resources/skeleton/crud/templates/edit.tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
{% block body %}
44
<h1>Edit <?= $entity_class_name ?></h1>
55

6-
{{ include('<?= $route_name ?>/_form.html.twig', {'button_label': 'Update'}) }}
6+
{{ include('<?= $templates_path ?>/_form.html.twig', {'button_label': 'Update'}) }}
77

88
<a href="{{ path('<?= $route_name ?>_index') }}">back to list</a>
99

10-
{{ include('<?= $route_name ?>/_delete_form.html.twig') }}
10+
{{ include('<?= $templates_path ?>/_delete_form.html.twig') }}
1111
{% endblock %}

src/Resources/skeleton/crud/templates/new.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block body %}
44
<h1>Create new <?= $entity_class_name ?></h1>
55

6-
{{ include('<?= $route_name ?>/_form.html.twig') }}
6+
{{ include('<?= $templates_path ?>/_form.html.twig') }}
77

88
<a href="{{ path('<?= $route_name ?>_index') }}">back to list</a>
99
{% endblock %}

src/Resources/skeleton/crud/templates/show.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818

1919
<a href="{{ path('<?= $route_name ?>_edit', {'<?= $entity_identifier ?>': <?= $entity_twig_var_singular ?>.<?= $entity_identifier ?>}) }}">edit</a>
2020

21-
{{ include('<?= $route_name ?>/_delete_form.html.twig') }}
21+
{{ include('<?= $templates_path ?>/_delete_form.html.twig') }}
2222
{% endblock %}

0 commit comments

Comments
 (0)