Skip to content

Commit 4e274aa

Browse files
committed
Better CRUD controller
1 parent 2664394 commit 4e274aa

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Resources/skeleton/crud/controller/Controller.tpl.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class <?= $class_name ?> extends <?= $parent_class_name; ?><?= "\n" ?>
2323
<?php if (isset($repository_full_class_name)): ?>
2424
public function index(<?= $repository_class_name ?> $<?= $repository_var ?>): Response
2525
{
26-
return $this->render('<?= $templates_path ?>/index.html.twig', ['<?= $entity_twig_var_plural ?>' => $<?= $repository_var ?>->findAll()]);
26+
return $this->render('<?= $templates_path ?>/index.html.twig', [
27+
'<?= $entity_twig_var_plural ?>' => $<?= $repository_var ?>->findAll(),
28+
]);
2729
}
2830
<?php else: ?>
2931
public function index(): Response
@@ -32,7 +34,9 @@ public function index(): Response
3234
->getRepository(<?= $entity_class_name ?>::class)
3335
->findAll();
3436

35-
return $this->render('<?= $templates_path ?>/index.html.twig', ['<?= $entity_twig_var_plural ?>' => $<?= $entity_var_plural ?>]);
37+
return $this->render('<?= $templates_path ?>/index.html.twig', [
38+
'<?= $entity_twig_var_plural ?>' => $<?= $entity_var_plural ?>,
39+
]);
3640
}
3741
<?php endif ?>
3842

@@ -64,7 +68,9 @@ public function new(Request $request): Response
6468
*/
6569
public function show(<?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response
6670
{
67-
return $this->render('<?= $templates_path ?>/show.html.twig', ['<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>]);
71+
return $this->render('<?= $templates_path ?>/show.html.twig', [
72+
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
73+
]);
6874
}
6975

7076
/**
@@ -78,7 +84,9 @@ public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_va
7884
if ($form->isSubmitted() && $form->isValid()) {
7985
$this->getDoctrine()->getManager()->flush();
8086

81-
return $this->redirectToRoute('<?= $route_name ?>_edit', ['<?= $entity_identifier ?>' => $<?= $entity_var_singular ?>->get<?= ucfirst($entity_identifier) ?>()]);
87+
return $this->redirectToRoute('<?= $route_name ?>_edit', [
88+
'<?= $entity_identifier ?>' => $<?= $entity_var_singular ?>->get<?= ucfirst($entity_identifier) ?>(),
89+
]);
8290
}
8391

8492
return $this->render('<?= $templates_path ?>/edit.html.twig', [

0 commit comments

Comments
 (0)