lucent config
This commit is contained in:
@@ -9,6 +9,7 @@ final class Channel
|
||||
{
|
||||
public string $lucentUrl;
|
||||
public string $filesUrl;
|
||||
public string $previewTargetUrl;
|
||||
|
||||
/**
|
||||
* @param Collection<Schema> $schemas
|
||||
@@ -20,11 +21,11 @@ final class Channel
|
||||
public string $generateCommand,
|
||||
public Collection $schemas,
|
||||
public array $imageFilters,
|
||||
// public Collection $previewTargets,
|
||||
)
|
||||
{
|
||||
$this->lucentUrl = $url . "/lucent";
|
||||
$this->filesUrl = $url . "/storage";
|
||||
$this->previewTargetUrl = $url . "/". $previewTarget;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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