Changeset View
Changeset View
Standalone View
Standalone View
src/app/Utils.php
Show First 20 Lines • Show All 454 Lines • ▼ Show 20 Lines | private static function combine($input, $r, $index, $data, $i, &$output): void | ||||
// current is excluded, replace it with next (Note that i+1 | // current is excluded, replace it with next (Note that i+1 | ||||
// is passed, but index is not changed) | // is passed, but index is not changed) | ||||
self::combine($input, $r, $index, $data, $i + 1, $output); | self::combine($input, $r, $index, $data, $i + 1, $output); | ||||
} | } | ||||
/** | /** | ||||
* Create self URL | * Create self URL | ||||
* | * | ||||
* @param string $route Route/Path | * @param string $route Route/Path/URL | ||||
* @param int|null $tenantId Current tenant | * @param int|null $tenantId Current tenant | ||||
* | * | ||||
* @todo Move this to App\Http\Controllers\Controller | * @todo Move this to App\Http\Controllers\Controller | ||||
* | * | ||||
* @return string Full URL | * @return string Full URL | ||||
*/ | */ | ||||
public static function serviceUrl(string $route, $tenantId = null): string | public static function serviceUrl(string $route, $tenantId = null): string | ||||
{ | { | ||||
if (preg_match('|^https?://|i', $route)) { | |||||
return $route; | |||||
} | |||||
$url = \App\Tenant::getConfig($tenantId, 'app.public_url'); | $url = \App\Tenant::getConfig($tenantId, 'app.public_url'); | ||||
if (!$url) { | if (!$url) { | ||||
$url = \App\Tenant::getConfig($tenantId, 'app.url'); | $url = \App\Tenant::getConfig($tenantId, 'app.url'); | ||||
} | } | ||||
return rtrim(trim($url, '/') . '/' . ltrim($route, '/'), '/'); | return rtrim(trim($url, '/') . '/' . ltrim($route, '/'), '/'); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |