diff --git a/src/GeneratorTwigHelper.php b/src/GeneratorTwigHelper.php index 60957b2e2..68157a010 100644 --- a/src/GeneratorTwigHelper.php +++ b/src/GeneratorTwigHelper.php @@ -41,11 +41,11 @@ public function getEntityFieldPrintCode($entity, $field): string return $printCode; } - public function getHeadPrintCode($title): string + public function getHeadPrintCode($title, $templates_inherited): string { if ($this->fileManager->fileExists($this->fileManager->getPathForTemplate('base.html.twig'))) { return <<confirm('Do you want to inherit a custom template? [Custom]', false); + + if ($customTemplateAsk) { + $nameCustomTemplate = $this->customTemplate; + $customTemplate = $io->ask( + sprintf('Enter the location of your custom template (e.g. %s)', $nameCustomTemplate), + $nameCustomTemplate + ); + } + $this->interactSetGenerateTests($input, $io); } @@ -196,6 +208,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen $entityClassDetails ); + $customTemplate = $this->customTemplate; $templates = [ '_delete_form' => [ 'route_name' => $routeName, @@ -209,6 +222,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen 'entity_identifier' => $entityDoctrineDetails->getIdentifier(), 'route_name' => $routeName, 'templates_path' => $templatesPath, + 'templates_inherited' => $customTemplate, ], 'index' => [ 'entity_class_name' => $entityClassDetails->getShortName(), @@ -217,11 +231,13 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen 'entity_identifier' => $entityDoctrineDetails->getIdentifier(), 'entity_fields' => $entityDoctrineDetails->getDisplayFields(), 'route_name' => $routeName, + 'templates_inherited' => $customTemplate, ], 'new' => [ 'entity_class_name' => $entityClassDetails->getShortName(), 'route_name' => $routeName, 'templates_path' => $templatesPath, + 'templates_inherited' => $customTemplate, ], 'show' => [ 'entity_class_name' => $entityClassDetails->getShortName(), @@ -230,6 +246,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen 'entity_fields' => $entityDoctrineDetails->getDisplayFields(), 'route_name' => $routeName, 'templates_path' => $templatesPath, + 'templates_inherited' => $customTemplate, ], ]; diff --git a/src/Resources/skeleton/controller/twig_template.tpl.php b/src/Resources/skeleton/controller/twig_template.tpl.php index e06dfc7a3..96d81bd38 100644 --- a/src/Resources/skeleton/controller/twig_template.tpl.php +++ b/src/Resources/skeleton/controller/twig_template.tpl.php @@ -1,4 +1,4 @@ -getHeadPrintCode("Hello $class_name!"); ?> +getHeadPrintCode("Hello $class_name!", $templates_inherited); ?> {% block body %}