Skip to content

Commit

Permalink
[8.x] Add new VendorTagPublished event (#36458)
Browse files Browse the repository at this point in the history
* 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 <taylor@laravel.com>
  • Loading branch information
ryangjchandler and taylorotwell committed Mar 4, 2021
1 parent b063e22 commit 6cbe0eb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Illuminate/Foundation/Console/VendorPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -159,14 +160,18 @@ protected function publishTag($tag)
{
$published = false;

foreach ($this->pathsToPublish($tag) as $from => $to) {
$pathsToPublish = $this->pathsToPublish($tag);

foreach ($pathsToPublish as $from => $to) {
$this->publishItem($from, $to);

$published = true;
}

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

Expand Down
33 changes: 33 additions & 0 deletions src/Illuminate/Foundation/Events/VendorTagPublished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Illuminate\Foundation\Events;

class VendorTagPublished
{
/**
* The vendor tag that was published.
*
* @var string
*/
public $tag;

/**
* The publishable paths registered by the tag.
*
* @var array
*/
public $paths;

/**
* Create a new event instance.
*
* @param string $tag
* @param array $paths
* @return void
*/
public function __construct($tag, $paths)
{
$this->tag = $tag;
$this->paths = $paths;
}
}

0 comments on commit 6cbe0eb

Please sign in to comment.