Skip to content

Commit

Permalink
Extend from AbstractController when using Symfony 4.1 or higher
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Jul 26, 2018
1 parent d49200d commit 2e6403b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Maker/MakeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\MakerBundle\Maker;

use Doctrine\Common\Annotations\Annotation;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Generator;
Expand Down Expand Up @@ -55,6 +56,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$controllerClassNameDetails->getFullName(),
'controller/Controller.tpl.php',
[
'parent_class_name' => \method_exists(AbstractController::class, 'getParameter') ? 'AbstractController' : 'Controller',
'route_path' => Str::asRoutePath($controllerClassNameDetails->getRelativeNameWithoutSuffix()),
'route_name' => Str::asRouteName($controllerClassNameDetails->getRelativeNameWithoutSuffix()),
'twig_installed' => $this->isTwigInstalled(),
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/skeleton/controller/Controller.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace <?= $namespace; ?>;

use Symfony\Bundle\FrameworkBundle\Controller\<?= $parent_class_name; ?>;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

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

0 comments on commit 2e6403b

Please sign in to comment.