From 0a580d43b6a7dd9cab4a9dea3d8fe550dbfcf714 Mon Sep 17 00:00:00 2001 From: Aselsan Date: Mon, 24 Jun 2024 13:17:17 +0700 Subject: [PATCH 1/4] feat: add Outbox Config into the current application config. --- src/Commands/OutboxPublish.php | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/Commands/OutboxPublish.php diff --git a/src/Commands/OutboxPublish.php b/src/Commands/OutboxPublish.php new file mode 100644 index 0000000..d912b87 --- /dev/null +++ b/src/Commands/OutboxPublish.php @@ -0,0 +1,42 @@ +getNamespace('Tatter\\Outbox')[0]; + + $publisher = new Publisher($source, APPPATH); + + try { + $publisher->addPaths([ + 'Config/Outbox.php', + ])->merge(false); + } catch (Throwable $e) { + $this->showError($e); + + return; + } + + foreach ($publisher->getPublished() as $file) { + $contents = file_get_contents($file); + $contents = str_replace('namespace Tatter\\Outbox\\Config', 'namespace Config', $contents); + $contents = str_replace('use CodeIgniter\\Config\\BaseConfig', 'use Tatter\\Outbox\\Config\\Outbox as BaseOutbox', $contents); + $contents = str_replace('class Outbox extends BaseConfig', 'class Outbox extends BaseOutbox', $contents); + file_put_contents($file, $contents); + } + + CLI::write(CLI::color(' Published! ', 'green') . 'You can customize the configuration by editing the "app/Config/Oubox.php" file.'); + } +} From 5e92e8f495530763df74aa5c3728744a8f1743a3 Mon Sep 17 00:00:00 2001 From: Aselsan Date: Mon, 24 Jun 2024 13:25:12 +0700 Subject: [PATCH 2/4] doc: update Configuration section in README.md --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b048ba..3fe51b2 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,11 @@ Or, install manually by downloading the source files and adding the directory to ## Configuration (optional) -The library's default behavior can be altered by extending its config file. Copy -**examples/Outbox.php** to **app/Config/** and follow the instructions +The library's default behavior can be altered by extending its config file. You can create config file using this command +```shell +php spark outbox:publish +``` +Or, manually by copy **examples/Outbox.php** to **app/Config/** and follow the instructions in the comments. If no config file is found in **app/Config** then the library will use its own. If you plan to use the Template Routes (see below) you might also want to configure From 03d0d07a92320bb46c84d1632723f2b916425c86 Mon Sep 17 00:00:00 2001 From: Aselsan Date: Fri, 5 Jul 2024 17:27:21 +0700 Subject: [PATCH 3/4] update typo src/Commands/OutboxPublish.php Co-authored-by: MGatner --- src/Commands/OutboxPublish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/OutboxPublish.php b/src/Commands/OutboxPublish.php index d912b87..8de47bd 100644 --- a/src/Commands/OutboxPublish.php +++ b/src/Commands/OutboxPublish.php @@ -11,7 +11,7 @@ class OutboxPublish extends BaseCommand { protected $group = 'Outbox'; protected $name = 'outbox:publish'; - protected $description = 'Publish Oubox config file into the current application.'; + protected $description = 'Publish Outbox config file into the current application.'; public function run(array $params): void { From 97d1a0287e9abc08928181e96b52777afbff2129 Mon Sep 17 00:00:00 2001 From: Aselsan Date: Fri, 5 Jul 2024 17:31:02 +0700 Subject: [PATCH 4/4] fix: small typo in OutboxPublish.php --- src/Commands/OutboxPublish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/OutboxPublish.php b/src/Commands/OutboxPublish.php index 8de47bd..f2bbc1d 100644 --- a/src/Commands/OutboxPublish.php +++ b/src/Commands/OutboxPublish.php @@ -37,6 +37,6 @@ public function run(array $params): void file_put_contents($file, $contents); } - CLI::write(CLI::color(' Published! ', 'green') . 'You can customize the configuration by editing the "app/Config/Oubox.php" file.'); + CLI::write(CLI::color(' Published! ', 'green') . 'You can customize the configuration by editing the "app/Config/Outbox.php" file.'); } }