Skip to content

Commit

Permalink
Extend from AbstractController and use Symfony's Route
Browse files Browse the repository at this point in the history
  • Loading branch information
royklutman committed Aug 11, 2018
1 parent a1b0d9f commit 07166c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Maker/MakeCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Common\Inflector\Inflector;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper;
Expand All @@ -27,6 +27,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Csrf\CsrfTokenManager;
use Symfony\Component\Validator\Validation;

Expand Down Expand Up @@ -130,6 +131,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$controllerClassDetails->getFullName(),
'crud/controller/Controller.tpl.php',
array_merge([
'parent_class_name' => \method_exists(AbstractController::class, 'getParameter') ? 'AbstractController' : 'Controller',
'entity_full_class_name' => $entityClassDetails->getFullName(),
'entity_class_name' => $entityClassDetails->getShortName(),
'form_full_class_name' => $formClassDetails->getFullName(),
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/skeleton/crud/controller/Controller.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<?php if (isset($repository_full_class_name)): ?>
use <?= $repository_full_class_name ?>;
<?php endif ?>
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\<?= $parent_class_name ?>;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("<?= $route_path ?>")
*/
class <?= $class_name ?> extends Controller
class <?= $class_name ?> extends <?= $parent_class_name ?>
{
/**
* @Route("/", name="<?= $route_name ?>_index", methods="GET")
Expand Down

0 comments on commit 07166c9

Please sign in to comment.