Skip to content

Commit 7b5c342

Browse files
committed
minor #914 [make:registration] cleanup maker and template (jrushlow)
This PR was squashed before being merged into the 1.0-dev branch. Discussion ---------- [make:registration] cleanup maker and template - Implements a new use statement sorter for templates - use class properties instead of abusing command arguments Commits ------- 771444d [make:registration] cleanup maker and template
2 parents d2dcd33 + 771444d commit 7b5c342

File tree

5 files changed

+232
-130
lines changed

5 files changed

+232
-130
lines changed

src/Generator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\MakerBundle;
1313

1414
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
15+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
1516
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
1617
use Symfony\Bundle\MakerBundle\Util\ClassNameDetails;
1718
use Symfony\Bundle\MakerBundle\Util\PhpCompatUtil;
@@ -223,7 +224,7 @@ public function generateController(string $controllerClassName, string $controll
223224
$controllerTemplatePath,
224225
$parameters +
225226
[
226-
'parent_class_name' => method_exists(AbstractController::class, 'getParameter') ? 'AbstractController' : 'Controller',
227+
'parent_class_name' => static::getControllerBaseClass()->getShortName(),
227228
]
228229
);
229230
}
@@ -239,4 +240,12 @@ public function generateTemplate(string $targetPath, string $templateName, array
239240
$variables
240241
);
241242
}
243+
244+
public static function getControllerBaseClass(): ClassNameDetails
245+
{
246+
// Support for Controller::class can be dropped when FrameworkBundle minimum supported version is >=4.1
247+
$class = method_exists(AbstractController::class, 'getParameter') ? AbstractController::class : Controller::class;
248+
249+
return new ClassNameDetails($class, '\\');
250+
}
242251
}

0 commit comments

Comments
 (0)