GeneaLabs /
laravel-imagery
| 1 | <?php namespace GeneaLabs\LaravelImagery\Console\Commands; |
||
| 2 | |||
| 3 | use File; |
||
| 4 | use GeneaLabs\LaravelImagery\Providers\LaravelImageryService; |
||
| 5 | use Illuminate\Console\Command; |
||
| 6 | use Illuminate\Contracts\Console\Kernel; |
||
| 7 | |||
| 8 | class Publish extends Command |
||
| 9 | { |
||
| 10 | protected $signature = 'imagery:publish {--assets} {--config}'; |
||
| 11 | protected $description = 'Publish various assets of the Laravel Imagery package.'; |
||
| 12 | |||
| 13 | public function handle() |
||
| 14 | { |
||
| 15 | if ($this->option('assets')) { |
||
| 16 | $this->delTree(public_path('genealabs-laravel-imagery')); |
||
| 17 | $this->call('vendor:publish', [ |
||
| 18 | '--provider' => LaravelImageryService::class, |
||
| 19 | '--tag' => ['assets'], |
||
| 20 | '--force' => true, |
||
| 21 | ]); |
||
| 22 | } |
||
| 23 | |||
| 24 | if ($this->option('config')) { |
||
| 25 | $this->call('vendor:publish', [ |
||
| 26 | '--provider' => LaravelImageryService::class, |
||
| 27 | '--tag' => ['config'], |
||
| 28 | '--force' => true, |
||
| 29 | ]); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | private function delTree($folder) |
||
| 34 | { |
||
| 35 | if (! is_dir($folder)) { |
||
| 36 | return false; |
||
| 37 | } |
||
| 38 | |||
| 39 | $files = array_diff(scandir($folder), ['.','..']); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 40 | |||
| 41 | foreach ($files as $file) { |
||
| 42 | is_dir("$folder/$file") ? $this->delTree("$folder/$file") : unlink("$folder/$file"); |
||
| 43 | } |
||
| 44 | |||
| 45 | return rmdir($folder); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |