Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_global_api #19

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Core/Traits/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ trait Config
private static bool $USE_DEFAULT_ROUTE = true;
private static bool $COMPRESS_HTML;
private static string $SESSION_KEY = "__LAY_VARS__";
private static string $GLOBAL_API;

private function header_data(string $key, mixed $value): self
{
Expand Down Expand Up @@ -236,9 +237,14 @@ public function dont_cache_domains(): self

public function set_global_api(string $uri): self
{
return $this->header_data("api", $uri);
self::$GLOBAL_API = $uri;
return $this;
}

public function get_global_api(): ?string
{
return self::$GLOBAL_API ?? null;
}

public function init_name(string $short, string $full): self
{
Expand Down
1 change: 0 additions & 1 deletion src/Core/Traits/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ private static function initialize() : self {
# Used by the Domain module to instruct the handler to cache all the listed domains in a session or cookie,
# depending on the value sent by dev
"cache_domains" => $options['switch']['cache_domains'] ?? true,
"global_api" => $options['header']['api'] ?? null,
"using_domain" => $options['header']['using_domain'] ?? null,
"using_web" => $options['header']['using_web'] ?? null,
"use_domain_file" => null, // this is updated when webroot is created after first class is init
Expand Down
2 changes: 1 addition & 1 deletion src/Core/View/ViewEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private function create_html_page() : void {
$client = DomainResource::get();
$page = $meta->{self::key_page};

$lay_api = $site_data->global_api ?? $site_data->domain . "api/";
$lay_api = $layConfig->get_global_api() ?? $site_data->domain . "api/";
$img = ViewSrc::gen($page->img ?? $client->shared->img_default->meta ?? $client->shared->img_default->logo);
$favicon = ViewSrc::gen($client->shared->img_default->favicon);
$author = $page->author ?? $site_data->author;
Expand Down