8000 Extend from AbstractController and use Symfony's Route · symfony/maker-bundle@07166c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 07166c9

Browse files
committed
Extend from AbstractController and use Symfony's Route
1 parent a1b0d9f commit 07166c9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Maker/MakeCrud.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
1515
use Doctrine\Common\Inflector\Inflector;
16-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
16+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1717
use Symfony\Bundle\MakerBundle\ConsoleStyle;
1818
use Symfony\Bundle\MakerBundle\DependencyBuilder;
1919
use Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper;
@@ -27,6 +27,7 @@
2727
use Symfony\Component\Console\Input\InputInterface;
2828
use Symfony\Component\Console\Question\Question;
2929
use Symfony\Component\Form\AbstractType;
30+
use Symfony\Component\Routing\Annotation\Route;
3031
use Symfony\Component\Security\Csrf\CsrfTokenManager;
3132
use Symfony\Component\Validator\Validation;
3233

@@ -130,6 +131,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
130131
$controllerClassDetails->getFullName(),
131132
'crud/controller/Controller.tpl.php',
132133
array_merge([
134+
'parent_class_name' => \method_exists(AbstractController::class, 'getParameter') ? 'AbstractController' : 'Controller',
133135
'entity_full_class_name' => $entityClassDetails->getFullName(),
134136
'entity_class_name' => $entityClassDetails->getShortName(),
135137
'form_full_class_name' => $formClassDetails->getFullName(),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
<?php if (isset($repository_full_class_name)): ?>
88
use <?= $repository_full_class_name ?>;
99
<?php endif ?>
10-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
10+
use Symfony\Bundle\FrameworkBundle\Controller\<?= $parent_class_name ?>;
1111
use Symfony\Component\HttpFoundation\Request;
1212
use Symfony\Component\HttpFoundation\Response;
1313
use Symfony\Component\Routing\Annotation\Route;
1414

1515
/**
1616
* @Route("<?= $route_path ?>")
1717
*/
18-
class <?= $class_name ?> extends Controller
18+
class <?= $class_name ?> extends <?= $parent_class_name ?>
1919
{
2020
/**
2121
* @Route("/", name="<?= $route_name ?>_index", methods="GET")

0 commit comments

Comments
 (0)
0