From 84d206a29530fafb5b83149a8d99b04a40f619b2 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Tue, 4 Apr 2023 16:14:19 +0100 Subject: [PATCH 1/3] added explanation for custom command generator templates --- user_guide_src/source/cli/cli_generators.rst | 11 +++++++++++ user_guide_src/source/cli/cli_generators/001.php | 13 +++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 user_guide_src/source/cli/cli_generators/001.php diff --git a/user_guide_src/source/cli/cli_generators.rst b/user_guide_src/source/cli/cli_generators.rst index 5a22c8b65cbc..03f7ded0cf9b 100644 --- a/user_guide_src/source/cli/cli_generators.rst +++ b/user_guide_src/source/cli/cli_generators.rst @@ -308,3 +308,14 @@ GeneratorTrait All generator commands must use the ``GeneratorTrait`` to fully utilize its methods that are used in code generation. + +************************************* +Accessing a Custom Generator Template +************************************* + +By default, all generator templates will be looked up at the ``CodeIgniter\Commands\Generators\Views`` namespace. +To declare a custom location for your custom generator template, you will need to add it to the ``app/Config/Generators.php`` +file. For example, if you have a command ``make:awesome-command`` and your generator template is located within your *app* +directory ``app/Commands/Generators/Views/awesomecommand.tpl.php``, you would update the config file like so: + +.. literalinclude:: cli_generators/001.php diff --git a/user_guide_src/source/cli/cli_generators/001.php b/user_guide_src/source/cli/cli_generators/001.php new file mode 100644 index 000000000000..5e9b1165697c --- /dev/null +++ b/user_guide_src/source/cli/cli_generators/001.php @@ -0,0 +1,13 @@ + 'App\Commands\Generators\awesomecommand.tpl.php', + ]; +} From a12263b775ca5534a31218ef94fcd3c51d020ad3 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Thu, 6 Apr 2023 11:17:21 +0100 Subject: [PATCH 2/3] applied code review suggestion --- user_guide_src/source/cli/cli_generators.rst | 14 ++++++++------ user_guide_src/source/cli/cli_generators/001.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/user_guide_src/source/cli/cli_generators.rst b/user_guide_src/source/cli/cli_generators.rst index 03f7ded0cf9b..763d82043e16 100644 --- a/user_guide_src/source/cli/cli_generators.rst +++ b/user_guide_src/source/cli/cli_generators.rst @@ -309,13 +309,15 @@ GeneratorTrait All generator commands must use the ``GeneratorTrait`` to fully utilize its methods that are used in code generation. -************************************* -Accessing a Custom Generator Template -************************************* +************************************************************* +Declaring the Location of a Custom Generator Command Template +************************************************************* -By default, all generator templates will be looked up at the ``CodeIgniter\Commands\Generators\Views`` namespace. -To declare a custom location for your custom generator template, you will need to add it to the ``app/Config/Generators.php`` +The default order of lookup for generator templates is first, the template defined in the **app/Config/Generators.php** file, +and if not found, the template will be looked up at the ``CodeIgniter\Commands\Generators\Views`` namespace. + +To declare the template location for your custom generator command, you will need to add it to the **app/Config/Generators.php** file. For example, if you have a command ``make:awesome-command`` and your generator template is located within your *app* -directory ``app/Commands/Generators/Views/awesomecommand.tpl.php``, you would update the config file like so: +directory **app/Commands/Generators/Views/awesomecommand.tpl.php**, you would update the config file like so: .. literalinclude:: cli_generators/001.php diff --git a/user_guide_src/source/cli/cli_generators/001.php b/user_guide_src/source/cli/cli_generators/001.php index 5e9b1165697c..26356cf34741 100644 --- a/user_guide_src/source/cli/cli_generators/001.php +++ b/user_guide_src/source/cli/cli_generators/001.php @@ -8,6 +8,6 @@ class Generators extends BaseConfig { public array $views = [ // .. - 'make:awesome-command' => 'App\Commands\Generators\awesomecommand.tpl.php', + 'make:awesome-command' => 'App\Commands\Generators\Views\awesomecommand.tpl.php', ]; } From abf37344d71c44839516632c4441beeb3005219b Mon Sep 17 00:00:00 2001 From: Samuel Asor <8720569+sammyskills@users.noreply.github.com> Date: Thu, 6 Apr 2023 12:32:44 +0100 Subject: [PATCH 3/3] Update user_guide_src/source/cli/cli_generators.rst Co-authored-by: John Paul E. Balandan, CPA --- user_guide_src/source/cli/cli_generators.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/cli/cli_generators.rst b/user_guide_src/source/cli/cli_generators.rst index 763d82043e16..d66255bd1f18 100644 --- a/user_guide_src/source/cli/cli_generators.rst +++ b/user_guide_src/source/cli/cli_generators.rst @@ -313,8 +313,8 @@ generation. Declaring the Location of a Custom Generator Command Template ************************************************************* -The default order of lookup for generator templates is first, the template defined in the **app/Config/Generators.php** file, -and if not found, the template will be looked up at the ``CodeIgniter\Commands\Generators\Views`` namespace. +The default order of lookup for generator templates is (1) the template defined in the **app/Config/Generators.php** file, +and (2) if not found, the template found at the ``CodeIgniter\Commands\Generators\Views`` namespace. To declare the template location for your custom generator command, you will need to add it to the **app/Config/Generators.php** file. For example, if you have a command ``make:awesome-command`` and your generator template is located within your *app*