Skip to content

Commit 6cbe0eb

Browse files
[8.x] Add new VendorTagPublished event (#36458)
* feature: add new VendorTagPublished event * fix: only fire event when something was published * refactor: fire event before erroring in console * revert: move event dispatch into else arm * chore: update comment on $paths * chore: publish to publishable * chore: add missing comment * Update VendorPublishCommand.php * Update VendorTagPublished.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent b063e22 commit 6cbe0eb

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/Illuminate/Foundation/Console/VendorPublishCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Filesystem\Filesystem;
7+
use Illuminate\Foundation\Events\VendorTagPublished;
78
use Illuminate\Support\Arr;
89
use Illuminate\Support\ServiceProvider;
910
use League\Flysystem\Adapter\Local as LocalAdapter;
@@ -159,14 +160,18 @@ protected function publishTag($tag)
159160
{
160161
$published = false;
161162

162-
foreach ($this->pathsToPublish($tag) as $from => $to) {
163+
$pathsToPublish = $this->pathsToPublish($tag);
164+
165+
foreach ($pathsToPublish as $from => $to) {
163166
$this->publishItem($from, $to);
164167

165168
$published = true;
166169
}
167170

168171
if ($published === false) {
169172
$this->error('Unable to locate publishable resources.');
173+
} else {
174+
$this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish));
170175
}
171176
}
172177

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Illuminate\Foundation\Events;
4+
5+
class VendorTagPublished
6+
{
7+
/**
8+
* The vendor tag that was published.
9+
*
10+
* @var string
11+
*/
12+
public $tag;
13+
14+
/**
15+
* The publishable paths registered by the tag.
16+
*
17+
* @var array
18+
*/
19+
public $paths;
20+
21+
/**
22+
* Create a new event instance.
23+
*
24+
* @param string $tag
25+
* @param array $paths
26+
* @return void
27+
*/
28+
public function __construct($tag, $paths)
29+
{
30+
$this->tag = $tag;
31+
$this->paths = $paths;
32+
}
33+
}

0 commit comments

Comments
 (0)