From 4cadadc0e7cfd7bbd2ec6b12fd6ab0ff899e4e84 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 4 Mar 2021 11:48:31 +0000 Subject: [PATCH 1/9] feature: add new VendorTagPublished event --- .../Console/VendorPublishCommand.php | 6 +++- .../Foundation/Events/VendorTagPublished.php | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Illuminate/Foundation/Events/VendorTagPublished.php diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 17a459e72834..31fe52762ee2 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Command; use Illuminate\Filesystem\Filesystem; +use Illuminate\Foundation\Events\VendorTagPublished; use Illuminate\Support\Arr; use Illuminate\Support\ServiceProvider; use League\Flysystem\Adapter\Local as LocalAdapter; @@ -158,8 +159,9 @@ protected function parseChoice($choice) protected function publishTag($tag) { $published = false; + $pathsToPublish = $this->pathsToPublish($tag); - foreach ($this->pathsToPublish($tag) as $from => $to) { + foreach ($pathsToPublish as $from => $to) { $this->publishItem($from, $to); $published = true; @@ -168,6 +170,8 @@ protected function publishTag($tag) if ($published === false) { $this->error('Unable to locate publishable resources.'); } + + $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); } /** diff --git a/src/Illuminate/Foundation/Events/VendorTagPublished.php b/src/Illuminate/Foundation/Events/VendorTagPublished.php new file mode 100644 index 000000000000..5330c5a1d894 --- /dev/null +++ b/src/Illuminate/Foundation/Events/VendorTagPublished.php @@ -0,0 +1,32 @@ +tag = $tag; + $this->paths = $paths; + } +} From 08b48c1a664134a365e1c7469909dc029d79f5e3 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 4 Mar 2021 11:56:22 +0000 Subject: [PATCH 2/9] fix: only fire event when something was published --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 31fe52762ee2..eedd26ca72c9 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -169,9 +169,9 @@ protected function publishTag($tag) if ($published === false) { $this->error('Unable to locate publishable resources.'); + } else { + $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); } - - $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); } /** From 390b609f693ed13658ea4d3dac38213f29857f9e Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 4 Mar 2021 11:59:13 +0000 Subject: [PATCH 3/9] refactor: fire event before erroring in console --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index eedd26ca72c9..0673ac79b2f0 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -167,10 +167,10 @@ protected function publishTag($tag) $published = true; } + $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); + if ($published === false) { $this->error('Unable to locate publishable resources.'); - } else { - $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); } } From ddb1d024da7797f3dc9bce2dfb41440681f5cf54 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 4 Mar 2021 12:11:11 +0000 Subject: [PATCH 4/9] revert: move event dispatch into else arm --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 0673ac79b2f0..eedd26ca72c9 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -167,10 +167,10 @@ protected function publishTag($tag) $published = true; } - $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); - if ($published === false) { $this->error('Unable to locate publishable resources.'); + } else { + $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); } } From 385f6823acfe165204f7fb7a4e54081d56728bac Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 4 Mar 2021 12:12:30 +0000 Subject: [PATCH 5/9] chore: update comment on $paths --- src/Illuminate/Foundation/Events/VendorTagPublished.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Events/VendorTagPublished.php b/src/Illuminate/Foundation/Events/VendorTagPublished.php index 5330c5a1d894..a0bae99c6542 100644 --- a/src/Illuminate/Foundation/Events/VendorTagPublished.php +++ b/src/Illuminate/Foundation/Events/VendorTagPublished.php @@ -12,7 +12,7 @@ class VendorTagPublished public $tag; /** - * The paths that were published. + * The publish paths registered by the tag. * * @var array */ From d3376b8f1812cc2294032bf5a8c57b4956416687 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 4 Mar 2021 12:14:24 +0000 Subject: [PATCH 6/9] chore: publish to publishable --- src/Illuminate/Foundation/Events/VendorTagPublished.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Events/VendorTagPublished.php b/src/Illuminate/Foundation/Events/VendorTagPublished.php index a0bae99c6542..137a719b1d13 100644 --- a/src/Illuminate/Foundation/Events/VendorTagPublished.php +++ b/src/Illuminate/Foundation/Events/VendorTagPublished.php @@ -12,7 +12,7 @@ class VendorTagPublished public $tag; /** - * The publish paths registered by the tag. + * The publishable paths registered by the tag. * * @var array */ From 8a25a0a2284ea0b5b1b1542f8baa6ad84b4c7398 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 4 Mar 2021 13:27:11 +0000 Subject: [PATCH 7/9] chore: add missing comment --- src/Illuminate/Foundation/Events/VendorTagPublished.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Foundation/Events/VendorTagPublished.php b/src/Illuminate/Foundation/Events/VendorTagPublished.php index 137a719b1d13..8b0ffa72b656 100644 --- a/src/Illuminate/Foundation/Events/VendorTagPublished.php +++ b/src/Illuminate/Foundation/Events/VendorTagPublished.php @@ -22,6 +22,7 @@ class VendorTagPublished * Create a new event instance. * * @param string $tag + * @param array $paths * @return void */ public function __construct($tag, $paths) From 81d684764ee4a16d28a191f5f47f579a5a4a35ab Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 4 Mar 2021 08:05:48 -0600 Subject: [PATCH 8/9] Update VendorPublishCommand.php --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index eedd26ca72c9..501142f0d63c 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -159,6 +159,7 @@ protected function parseChoice($choice) protected function publishTag($tag) { $published = false; + $pathsToPublish = $this->pathsToPublish($tag); foreach ($pathsToPublish as $from => $to) { From 8a7318d716337ff39046db41b19714367ac96404 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 4 Mar 2021 08:06:12 -0600 Subject: [PATCH 9/9] Update VendorTagPublished.php --- src/Illuminate/Foundation/Events/VendorTagPublished.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Events/VendorTagPublished.php b/src/Illuminate/Foundation/Events/VendorTagPublished.php index 8b0ffa72b656..084c1293fcfd 100644 --- a/src/Illuminate/Foundation/Events/VendorTagPublished.php +++ b/src/Illuminate/Foundation/Events/VendorTagPublished.php @@ -5,7 +5,7 @@ class VendorTagPublished { /** - * The vendor tag published. + * The vendor tag that was published. * * @var string */