- UrlExtension now supports multiple application URL
This commit is contained in:
parent
3dce6a41cb
commit
215bc26981
|
@ -17,7 +17,7 @@ PATTERN;
|
||||||
|
|
||||||
protected string $urlBase;
|
protected string $urlBase;
|
||||||
|
|
||||||
protected string $appUrl;
|
protected array $appUrl;
|
||||||
|
|
||||||
protected string $assetToken;
|
protected string $assetToken;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ PATTERN;
|
||||||
#[\Deprecated]
|
#[\Deprecated]
|
||||||
protected bool $enforceExistingArguments = true;
|
protected bool $enforceExistingArguments = true;
|
||||||
|
|
||||||
public function __construct(string $urlBase = "", string $assetToken = "", string $appUrl = "", bool $forceSSL = false) {
|
public function __construct(string $urlBase = "", string $assetToken = "", array $appUrl = [], bool $forceSSL = false) {
|
||||||
$this->urlBase = trim($urlBase, "/");
|
$this->urlBase = trim($urlBase, "/");
|
||||||
$this->assetToken = $assetToken;
|
$this->assetToken = $assetToken;
|
||||||
$this->appUrl = $appUrl;
|
$this->appUrl = $appUrl;
|
||||||
|
@ -202,7 +202,18 @@ PATTERN;
|
||||||
$port = $this->isDefaultPort() ? "" : ":" . $_SERVER['SERVER_PORT'];
|
$port = $this->isDefaultPort() ? "" : ":" . $_SERVER['SERVER_PORT'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return strtolower($this->appUrl ? $this->appUrl . $port : $_SERVER['HTTP_HOST']);
|
return strtolower($this->appUrl($port) ?: $_SERVER['HTTP_HOST']);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function appUrl(string $port) : string
|
||||||
|
{
|
||||||
|
$domain = strtolower($_SERVER['HTTP_HOST']);
|
||||||
|
|
||||||
|
if (in_array($domain, $this->appUrl)) {
|
||||||
|
return $domain . $port;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->appUrl[0] . $port;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function isDefaultPort() : bool
|
protected function isDefaultPort() : bool
|
||||||
|
|
Loading…
Reference in New Issue