diff --git a/src/Generator.php b/src/Generator.php index aa9408311..6bc750981 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -81,7 +81,7 @@ public function generateClass(string $className, string $templateName, array $va * * @internal * - * @param string $templateName Template name in Resources/skeleton to use + * @param string $templateName Template name in the templates/ dir to use * @param array $variables Array of variables to pass to the template * @param bool $isController Set to true if generating a Controller that needs * access to the TemplateComponentGenerator ("generator") in @@ -299,10 +299,14 @@ private function addOperation(string $targetPath, string $templateName, array $v $templatePath = $templateName; if (!file_exists($templatePath)) { - $templatePath = __DIR__.'/Resources/skeleton/'.$templateName; + $templatePath = \sprintf('%s/templates/%s', \dirname(__DIR__), $templateName); if (!file_exists($templatePath)) { - throw new \Exception(\sprintf('Cannot find template "%s"', $templateName)); + $templatePath = $this->getTemplateFromLegacySkeletonPath($templateName); + } + + if (!file_exists($templatePath)) { + throw new \Exception(\sprintf('Cannot find template "%s" in the templates/ dir.', $templateName)); } } @@ -311,4 +315,27 @@ private function addOperation(string $targetPath, string $templateName, array $v 'variables' => $variables, ]; } + + /** + * @legacy - Remove when public generate methods become "internal" to MakerBundle in v2 + */ + private function getTemplateFromLegacySkeletonPath(string $templateName): string + { + $templatePath = $templateName; + if (!file_exists($templatePath)) { + $templatePath = __DIR__.'/Resources/skeleton/'.$templateName; + + if (!file_exists($templatePath)) { + throw new \Exception(\sprintf('Cannot find template "%s"', $templateName)); + } + } + + @trigger_deprecation( + 'symfony/maker-bundle', + '1.62.0', + 'Storing templates in src/Resources/skeleton is deprecated. Store MakerBundle templates in the "~/templates/" dir instead.', + ); + + return $templatePath; + } } diff --git a/src/Maker/MakeTwigComponent.php b/src/Maker/MakeTwigComponent.php index 91908ebe5..4bf55ee8d 100644 --- a/src/Maker/MakeTwigComponent.php +++ b/src/Maker/MakeTwigComponent.php @@ -79,14 +79,14 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen $generator->generateClass( $factory->getFullName(), - \sprintf('%s/../Resources/skeleton/twig/%s', __DIR__, $live ? 'LiveComponent.tpl.php' : 'Component.tpl.php'), + \sprintf('%s/templates/twig/%s', \dirname(__DIR__, 2), $live ? 'LiveComponent.tpl.php' : 'Component.tpl.php'), [ 'live' => $live, ] ); $generator->generateTemplate( "components/{$templatePath}.html.twig", - \sprintf('%s/../Resources/skeleton/twig/%s', __DIR__, 'component_template.tpl.php') + \sprintf('%s/templates/twig/%s', \dirname(__DIR__, 2), 'component_template.tpl.php') ); $generator->writeChanges(); diff --git a/src/Resources/skeleton/Class.tpl.php b/templates/Class.tpl.php similarity index 100% rename from src/Resources/skeleton/Class.tpl.php rename to templates/Class.tpl.php diff --git a/src/Resources/skeleton/authenticator/EmptyAuthenticator.tpl.php b/templates/authenticator/EmptyAuthenticator.tpl.php similarity index 100% rename from src/Resources/skeleton/authenticator/EmptyAuthenticator.tpl.php rename to templates/authenticator/EmptyAuthenticator.tpl.php diff --git a/src/Resources/skeleton/authenticator/EmptySecurityController.tpl.php b/templates/authenticator/EmptySecurityController.tpl.php similarity index 100% rename from src/Resources/skeleton/authenticator/EmptySecurityController.tpl.php rename to templates/authenticator/EmptySecurityController.tpl.php diff --git a/src/Resources/skeleton/authenticator/LoginFormAuthenticator.tpl.php b/templates/authenticator/LoginFormAuthenticator.tpl.php similarity index 100% rename from src/Resources/skeleton/authenticator/LoginFormAuthenticator.tpl.php rename to templates/authenticator/LoginFormAuthenticator.tpl.php diff --git a/src/Resources/skeleton/authenticator/login_form.tpl.php b/templates/authenticator/login_form.tpl.php similarity index 100% rename from src/Resources/skeleton/authenticator/login_form.tpl.php rename to templates/authenticator/login_form.tpl.php diff --git a/src/Resources/skeleton/command/Command.tpl.php b/templates/command/Command.tpl.php similarity index 100% rename from src/Resources/skeleton/command/Command.tpl.php rename to templates/command/Command.tpl.php diff --git a/src/Resources/skeleton/controller/Controller.tpl.php b/templates/controller/Controller.tpl.php similarity index 100% rename from src/Resources/skeleton/controller/Controller.tpl.php rename to templates/controller/Controller.tpl.php diff --git a/src/Resources/skeleton/controller/test/Test.tpl.php b/templates/controller/test/Test.tpl.php similarity index 100% rename from src/Resources/skeleton/controller/test/Test.tpl.php rename to templates/controller/test/Test.tpl.php diff --git a/src/Resources/skeleton/controller/twig_template.tpl.php b/templates/controller/twig_template.tpl.php similarity index 100% rename from src/Resources/skeleton/controller/twig_template.tpl.php rename to templates/controller/twig_template.tpl.php diff --git a/src/Resources/skeleton/crud/controller/Controller.tpl.php b/templates/crud/controller/Controller.tpl.php similarity index 100% rename from src/Resources/skeleton/crud/controller/Controller.tpl.php rename to templates/crud/controller/Controller.tpl.php diff --git a/src/Resources/skeleton/crud/templates/_delete_form.tpl.php b/templates/crud/templates/_delete_form.tpl.php similarity index 100% rename from src/Resources/skeleton/crud/templates/_delete_form.tpl.php rename to templates/crud/templates/_delete_form.tpl.php diff --git a/src/Resources/skeleton/crud/templates/_form.tpl.php b/templates/crud/templates/_form.tpl.php similarity index 100% rename from src/Resources/skeleton/crud/templates/_form.tpl.php rename to templates/crud/templates/_form.tpl.php diff --git a/src/Resources/skeleton/crud/templates/edit.tpl.php b/templates/crud/templates/edit.tpl.php similarity index 100% rename from src/Resources/skeleton/crud/templates/edit.tpl.php rename to templates/crud/templates/edit.tpl.php diff --git a/src/Resources/skeleton/crud/templates/index.tpl.php b/templates/crud/templates/index.tpl.php similarity index 100% rename from src/Resources/skeleton/crud/templates/index.tpl.php rename to templates/crud/templates/index.tpl.php diff --git a/src/Resources/skeleton/crud/templates/new.tpl.php b/templates/crud/templates/new.tpl.php similarity index 100% rename from src/Resources/skeleton/crud/templates/new.tpl.php rename to templates/crud/templates/new.tpl.php diff --git a/src/Resources/skeleton/crud/templates/show.tpl.php b/templates/crud/templates/show.tpl.php similarity index 100% rename from src/Resources/skeleton/crud/templates/show.tpl.php rename to templates/crud/templates/show.tpl.php diff --git a/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php b/templates/crud/test/Test.EntityManager.tpl.php similarity index 100% rename from src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php rename to templates/crud/test/Test.EntityManager.tpl.php diff --git a/src/Resources/skeleton/doctrine/Entity.tpl.php b/templates/doctrine/Entity.tpl.php similarity index 100% rename from src/Resources/skeleton/doctrine/Entity.tpl.php rename to templates/doctrine/Entity.tpl.php diff --git a/src/Resources/skeleton/doctrine/Fixtures.tpl.php b/templates/doctrine/Fixtures.tpl.php similarity index 100% rename from src/Resources/skeleton/doctrine/Fixtures.tpl.php rename to templates/doctrine/Fixtures.tpl.php diff --git a/src/Resources/skeleton/doctrine/Repository.tpl.php b/templates/doctrine/Repository.tpl.php similarity index 100% rename from src/Resources/skeleton/doctrine/Repository.tpl.php rename to templates/doctrine/Repository.tpl.php diff --git a/src/Resources/skeleton/doctrine/broadcast_twig_template.tpl.php b/templates/doctrine/broadcast_twig_template.tpl.php similarity index 100% rename from src/Resources/skeleton/doctrine/broadcast_twig_template.tpl.php rename to templates/doctrine/broadcast_twig_template.tpl.php diff --git a/src/Resources/skeleton/event/Listener.tpl.php b/templates/event/Listener.tpl.php similarity index 100% rename from src/Resources/skeleton/event/Listener.tpl.php rename to templates/event/Listener.tpl.php diff --git a/src/Resources/skeleton/event/Subscriber.tpl.php b/templates/event/Subscriber.tpl.php similarity index 100% rename from src/Resources/skeleton/event/Subscriber.tpl.php rename to templates/event/Subscriber.tpl.php diff --git a/src/Resources/skeleton/form/Type.tpl.php b/templates/form/Type.tpl.php similarity index 100% rename from src/Resources/skeleton/form/Type.tpl.php rename to templates/form/Type.tpl.php diff --git a/src/Resources/skeleton/message/Message.tpl.php b/templates/message/Message.tpl.php similarity index 100% rename from src/Resources/skeleton/message/Message.tpl.php rename to templates/message/Message.tpl.php diff --git a/src/Resources/skeleton/message/MessageHandler.tpl.php b/templates/message/MessageHandler.tpl.php similarity index 100% rename from src/Resources/skeleton/message/MessageHandler.tpl.php rename to templates/message/MessageHandler.tpl.php diff --git a/src/Resources/skeleton/middleware/Middleware.tpl.php b/templates/middleware/Middleware.tpl.php similarity index 100% rename from src/Resources/skeleton/middleware/Middleware.tpl.php rename to templates/middleware/Middleware.tpl.php diff --git a/src/Resources/skeleton/registration/RegistrationController.tpl.php b/templates/registration/RegistrationController.tpl.php similarity index 100% rename from src/Resources/skeleton/registration/RegistrationController.tpl.php rename to templates/registration/RegistrationController.tpl.php diff --git a/src/Resources/skeleton/registration/Test.WithVerify.tpl.php b/templates/registration/Test.WithVerify.tpl.php similarity index 100% rename from src/Resources/skeleton/registration/Test.WithVerify.tpl.php rename to templates/registration/Test.WithVerify.tpl.php diff --git a/src/Resources/skeleton/registration/Test.WithoutVerify.tpl.php b/templates/registration/Test.WithoutVerify.tpl.php similarity index 100% rename from src/Resources/skeleton/registration/Test.WithoutVerify.tpl.php rename to templates/registration/Test.WithoutVerify.tpl.php diff --git a/src/Resources/skeleton/registration/twig_email.tpl.php b/templates/registration/twig_email.tpl.php similarity index 100% rename from src/Resources/skeleton/registration/twig_email.tpl.php rename to templates/registration/twig_email.tpl.php diff --git a/src/Resources/skeleton/registration/twig_template.tpl.php b/templates/registration/twig_template.tpl.php similarity index 100% rename from src/Resources/skeleton/registration/twig_template.tpl.php rename to templates/registration/twig_template.tpl.php diff --git a/src/Resources/skeleton/resetPassword/ChangePasswordFormType.tpl.php b/templates/resetPassword/ChangePasswordFormType.tpl.php similarity index 100% rename from src/Resources/skeleton/resetPassword/ChangePasswordFormType.tpl.php rename to templates/resetPassword/ChangePasswordFormType.tpl.php diff --git a/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php b/templates/resetPassword/ResetPasswordController.tpl.php similarity index 100% rename from src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php rename to templates/resetPassword/ResetPasswordController.tpl.php diff --git a/src/Resources/skeleton/resetPassword/ResetPasswordRequestFormType.tpl.php b/templates/resetPassword/ResetPasswordRequestFormType.tpl.php similarity index 100% rename from src/Resources/skeleton/resetPassword/ResetPasswordRequestFormType.tpl.php rename to templates/resetPassword/ResetPasswordRequestFormType.tpl.php diff --git a/src/Resources/skeleton/resetPassword/Test.ResetPasswordController.tpl.php b/templates/resetPassword/Test.ResetPasswordController.tpl.php similarity index 100% rename from src/Resources/skeleton/resetPassword/Test.ResetPasswordController.tpl.php rename to templates/resetPassword/Test.ResetPasswordController.tpl.php diff --git a/src/Resources/skeleton/resetPassword/twig_check_email.tpl.php b/templates/resetPassword/twig_check_email.tpl.php similarity index 100% rename from src/Resources/skeleton/resetPassword/twig_check_email.tpl.php rename to templates/resetPassword/twig_check_email.tpl.php diff --git a/src/Resources/skeleton/resetPassword/twig_email.tpl.php b/templates/resetPassword/twig_email.tpl.php similarity index 100% rename from src/Resources/skeleton/resetPassword/twig_email.tpl.php rename to templates/resetPassword/twig_email.tpl.php diff --git a/src/Resources/skeleton/resetPassword/twig_request.tpl.php b/templates/resetPassword/twig_request.tpl.php similarity index 100% rename from src/Resources/skeleton/resetPassword/twig_request.tpl.php rename to templates/resetPassword/twig_request.tpl.php diff --git a/src/Resources/skeleton/resetPassword/twig_reset.tpl.php b/templates/resetPassword/twig_reset.tpl.php similarity index 100% rename from src/Resources/skeleton/resetPassword/twig_reset.tpl.php rename to templates/resetPassword/twig_reset.tpl.php diff --git a/src/Resources/skeleton/scheduler/Schedule.tpl.php b/templates/scheduler/Schedule.tpl.php similarity index 100% rename from src/Resources/skeleton/scheduler/Schedule.tpl.php rename to templates/scheduler/Schedule.tpl.php diff --git a/src/Resources/skeleton/security/UserProvider.tpl.php b/templates/security/UserProvider.tpl.php similarity index 100% rename from src/Resources/skeleton/security/UserProvider.tpl.php rename to templates/security/UserProvider.tpl.php diff --git a/src/Resources/skeleton/security/Voter.tpl.php b/templates/security/Voter.tpl.php similarity index 100% rename from src/Resources/skeleton/security/Voter.tpl.php rename to templates/security/Voter.tpl.php diff --git a/src/Resources/skeleton/security/custom/Authenticator.tpl.php b/templates/security/custom/Authenticator.tpl.php similarity index 100% rename from src/Resources/skeleton/security/custom/Authenticator.tpl.php rename to templates/security/custom/Authenticator.tpl.php diff --git a/src/Resources/skeleton/security/formLogin/LoginController.tpl.php b/templates/security/formLogin/LoginController.tpl.php similarity index 100% rename from src/Resources/skeleton/security/formLogin/LoginController.tpl.php rename to templates/security/formLogin/LoginController.tpl.php diff --git a/src/Resources/skeleton/security/formLogin/Test.LoginController.tpl.php b/templates/security/formLogin/Test.LoginController.tpl.php similarity index 100% rename from src/Resources/skeleton/security/formLogin/Test.LoginController.tpl.php rename to templates/security/formLogin/Test.LoginController.tpl.php diff --git a/src/Resources/skeleton/security/formLogin/login_form.tpl.php b/templates/security/formLogin/login_form.tpl.php similarity index 100% rename from src/Resources/skeleton/security/formLogin/login_form.tpl.php rename to templates/security/formLogin/login_form.tpl.php diff --git a/src/Resources/skeleton/serializer/Encoder.tpl.php b/templates/serializer/Encoder.tpl.php similarity index 100% rename from src/Resources/skeleton/serializer/Encoder.tpl.php rename to templates/serializer/Encoder.tpl.php diff --git a/src/Resources/skeleton/serializer/Normalizer.tpl.php b/templates/serializer/Normalizer.tpl.php similarity index 100% rename from src/Resources/skeleton/serializer/Normalizer.tpl.php rename to templates/serializer/Normalizer.tpl.php diff --git a/src/Resources/skeleton/stimulus/Controller.tpl.php b/templates/stimulus/Controller.tpl.php similarity index 100% rename from src/Resources/skeleton/stimulus/Controller.tpl.php rename to templates/stimulus/Controller.tpl.php diff --git a/src/Resources/skeleton/test/ApiTestCase.tpl.php b/templates/test/ApiTestCase.tpl.php similarity index 100% rename from src/Resources/skeleton/test/ApiTestCase.tpl.php rename to templates/test/ApiTestCase.tpl.php diff --git a/src/Resources/skeleton/test/Functional.tpl.php b/templates/test/Functional.tpl.php similarity index 100% rename from src/Resources/skeleton/test/Functional.tpl.php rename to templates/test/Functional.tpl.php diff --git a/src/Resources/skeleton/test/KernelTestCase.tpl.php b/templates/test/KernelTestCase.tpl.php similarity index 100% rename from src/Resources/skeleton/test/KernelTestCase.tpl.php rename to templates/test/KernelTestCase.tpl.php diff --git a/src/Resources/skeleton/test/PantherTestCase.tpl.php b/templates/test/PantherTestCase.tpl.php similarity index 100% rename from src/Resources/skeleton/test/PantherTestCase.tpl.php rename to templates/test/PantherTestCase.tpl.php diff --git a/src/Resources/skeleton/test/TestCase.tpl.php b/templates/test/TestCase.tpl.php similarity index 100% rename from src/Resources/skeleton/test/TestCase.tpl.php rename to templates/test/TestCase.tpl.php diff --git a/src/Resources/skeleton/test/Unit.tpl.php b/templates/test/Unit.tpl.php similarity index 100% rename from src/Resources/skeleton/test/Unit.tpl.php rename to templates/test/Unit.tpl.php diff --git a/src/Resources/skeleton/test/WebTestCase.tpl.php b/templates/test/WebTestCase.tpl.php similarity index 100% rename from src/Resources/skeleton/test/WebTestCase.tpl.php rename to templates/test/WebTestCase.tpl.php diff --git a/src/Resources/skeleton/twig/Component.tpl.php b/templates/twig/Component.tpl.php similarity index 100% rename from src/Resources/skeleton/twig/Component.tpl.php rename to templates/twig/Component.tpl.php diff --git a/src/Resources/skeleton/twig/Extension.tpl.php b/templates/twig/Extension.tpl.php similarity index 100% rename from src/Resources/skeleton/twig/Extension.tpl.php rename to templates/twig/Extension.tpl.php diff --git a/src/Resources/skeleton/twig/LiveComponent.tpl.php b/templates/twig/LiveComponent.tpl.php similarity index 100% rename from src/Resources/skeleton/twig/LiveComponent.tpl.php rename to templates/twig/LiveComponent.tpl.php diff --git a/src/Resources/skeleton/twig/Runtime.tpl.php b/templates/twig/Runtime.tpl.php similarity index 100% rename from src/Resources/skeleton/twig/Runtime.tpl.php rename to templates/twig/Runtime.tpl.php diff --git a/src/Resources/skeleton/twig/component_template.tpl.php b/templates/twig/component_template.tpl.php similarity index 100% rename from src/Resources/skeleton/twig/component_template.tpl.php rename to templates/twig/component_template.tpl.php diff --git a/src/Resources/skeleton/validator/Constraint.tpl.php b/templates/validator/Constraint.tpl.php similarity index 100% rename from src/Resources/skeleton/validator/Constraint.tpl.php rename to templates/validator/Constraint.tpl.php diff --git a/src/Resources/skeleton/validator/Validator.tpl.php b/templates/validator/Validator.tpl.php similarity index 100% rename from src/Resources/skeleton/validator/Validator.tpl.php rename to templates/validator/Validator.tpl.php diff --git a/src/Resources/skeleton/verifyEmail/EmailVerifier.tpl.php b/templates/verifyEmail/EmailVerifier.tpl.php similarity index 100% rename from src/Resources/skeleton/verifyEmail/EmailVerifier.tpl.php rename to templates/verifyEmail/EmailVerifier.tpl.php diff --git a/src/Resources/skeleton/webhook/RequestParser.tpl.php b/templates/webhook/RequestParser.tpl.php similarity index 100% rename from src/Resources/skeleton/webhook/RequestParser.tpl.php rename to templates/webhook/RequestParser.tpl.php diff --git a/src/Resources/skeleton/webhook/WebhookConsumer.tpl.php b/templates/webhook/WebhookConsumer.tpl.php similarity index 100% rename from src/Resources/skeleton/webhook/WebhookConsumer.tpl.php rename to templates/webhook/WebhookConsumer.tpl.php