lucent config
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Commands;
|
||||
|
||||
use DirectoryIterator;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CompileConfig extends Command
|
||||
{
|
||||
|
||||
protected $signature = 'lucent:config';
|
||||
|
||||
protected $description = 'Compiles Config';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$configDir = base_path(config('lucent.config_path'));
|
||||
|
||||
$configJson = file_get_contents($configDir . "/lucent.json");
|
||||
$config = json_decode($configJson, true);
|
||||
$schemasDirIterator = new DirectoryIterator($configDir . "/Schemas");
|
||||
$schemas = [];
|
||||
foreach ($schemasDirIterator as $file) {
|
||||
if ($file->getExtension() !== "json") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$schemaJson = file_get_contents($configDir . "/Schemas/" . $file->getFilename());
|
||||
$schema = json_decode($schemaJson, true);
|
||||
if (empty($schema)) {
|
||||
$this->error("Invalid JSON " . $file->getFilename());
|
||||
return 0;
|
||||
}
|
||||
$schemas[] = $schema;
|
||||
|
||||
}
|
||||
|
||||
$config["schemas"] = collect($schemas)->sortBy("label")->values()->toArray();
|
||||
$configOuputJson = json_encode($config);
|
||||
file_put_contents(storage_path("lucent.config.json"), $configOuputJson);
|
||||
|
||||
$this->info("Lucent JSON update");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Commands;
|
||||
|
||||
use DirectoryIterator;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CompileSchemas extends Command
|
||||
{
|
||||
|
||||
protected $signature = 'lucent:schemas';
|
||||
|
||||
protected $description = 'Compiles schemas';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$configDir = base_path(config('lucent.schemas_path'));
|
||||
$schemasDirIterator = new DirectoryIterator($configDir);
|
||||
$schemas = [];
|
||||
foreach ($schemasDirIterator as $file) {
|
||||
if ($file->getExtension() !== "json") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$schemaJson = file_get_contents($configDir . "/" . $file->getFilename());
|
||||
$schema = json_decode($schemaJson, true);
|
||||
if (empty($schema)) {
|
||||
$this->error("Invalid JSON " . $file->getFilename());
|
||||
return 0;
|
||||
}
|
||||
$schemas[] = $schema;
|
||||
|
||||
}
|
||||
|
||||
$schemas = collect($schemas)->sortBy("label")->values()->toArray();
|
||||
|
||||
if(!file_exists(storage_path("lucent"))){
|
||||
mkdir(storage_path("lucent"));
|
||||
}
|
||||
|
||||
file_put_contents(schemas_path(), json_encode($schemas));
|
||||
|
||||
$this->info("Lucent Schemas were updated");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user