blessing-skin-server/app/Listeners/CopyPluginAssets.php

30 lines
652 B
PHP
Raw Normal View History

2019-08-12 15:21:50 +08:00
<?php
namespace App\Listeners;
2019-09-09 23:08:03 +08:00
use App\Services\Plugin;
2019-08-12 15:21:50 +08:00
use Illuminate\Filesystem\Filesystem;
class CopyPluginAssets
{
2020-07-04 15:13:23 +08:00
/** @var Filesystem */
2019-08-12 15:21:50 +08:00
protected $filesystem;
public function __construct(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
}
2019-08-12 17:48:40 +08:00
public function handle($event)
2019-08-12 15:21:50 +08:00
{
2019-09-09 23:08:03 +08:00
$plugin = $event instanceof Plugin ? $event : $event->plugin;
2019-08-12 15:21:50 +08:00
$dir = public_path('plugins/'.$plugin->name);
$this->filesystem->deleteDirectory($dir);
$this->filesystem->copyDirectory(
$plugin->getPath().DIRECTORY_SEPARATOR.'assets',
$dir.'/assets'
);
}
}