lucent config
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user