blessing-skin-server/app/Console/Commands/OptionsCacheCommand.php

29 lines
844 B
PHP
Raw Normal View History

2019-08-21 23:46:38 +08:00
<?php
namespace App\Console\Commands;
use App\Services\Option;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
2019-08-26 11:01:49 +08:00
use Illuminate\Foundation\Application;
2019-08-21 23:46:38 +08:00
class OptionsCacheCommand extends Command
{
protected $signature = 'options:cache';
protected $description = 'Cache Blessing Skin options';
2019-08-26 11:01:49 +08:00
public function handle(Filesystem $filesystem, Application $app)
2019-08-21 23:46:38 +08:00
{
2019-12-23 23:28:46 +08:00
$path = storage_path('options.php');
2019-08-26 11:01:49 +08:00
$filesystem->delete($path);
$app->forgetInstance(Option::class);
$content = var_export(resolve(Option::class)->all(), true);
2019-12-23 23:28:46 +08:00
$notice = '// This is auto-generated. DO NOT edit manually.'.PHP_EOL;
$content = '<?php'.PHP_EOL.$notice.'return '.$content.';';
2019-08-26 11:01:49 +08:00
$filesystem->put($path, $content);
2019-08-21 23:46:38 +08:00
$this->info('Options cached successfully.');
}
}