lucent config

This commit is contained in:
2023-10-06 13:07:09 +03:00
parent 341ad267a5
commit 9bbe5ee9b4
9 changed files with 95 additions and 71 deletions
+10 -11
View File
@@ -21,25 +21,24 @@ final class ChannelService
public static function fromConfig(): ChannelService
{
if(file_exists(storage_path("lucent.config.json"))){
$configJson = file_get_contents(storage_path("lucent.config.json"));
$configArray = json_decode($configJson, true);
}else{
$configArray = null;
$schemasArray = [];
if(file_exists(schemas_path())){
$schemasJson = file_get_contents(schemas_path());
$schemasArray = json_decode($schemasJson, true);
}
$schemaService = new SchemaService();
$schemasCollection = (new Collection($configArray["schemas"] ?? []))->map([$schemaService, 'fromArray']);
$schemasCollection = (new Collection($schemasArray))->map([$schemaService, 'fromArray']);
$channel = new Channel(
name: $configArray["name"] ?? "",
url: rtrim($configArray["url"] ?? "", "/"),
previewTarget: rtrim($configArray["previewTarget"] ?? "", "/"),
generateCommand: $configArray["generateCommand"] ?? "",
name: config("lucent.name") ?? "",
url: rtrim( config("lucent.url") ?? "", "/"),
previewTarget: rtrim( config("lucent.previewTarget") ?? "", "/"),
generateCommand: config("lucent.generateCommand") ?? "",
schemas: $schemasCollection,
imageFilters: $configArray["imageFilters"] ?? [],
imageFilters: config("lucent.imageFilters") ?? [],
);
$channelService = new ChannelService($schemaService);
$channelService->channel = $channel;