- move helper functions inside app\Helpers\utils.php (e.g. get_domain

This commit is contained in:
Arno Kaimbacher 2021-06-08 09:59:39 +02:00
parent 35601144c8
commit 2040a9d260
2 changed files with 17 additions and 13 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Get an associative array with localeCodes as keys and translated URLs of current page as value * Get an associative array with localeCodes as keys and translated URLs of current page as value
*/ */
function getLocalizedURLArray() function getLocalizedURLArray()
{ {
$localesOrdered = LaravelLocalization::getLocalesOrder(); $localesOrdered = LaravelLocalization::getLocalesOrder();
@ -11,3 +11,18 @@ function getLocalizedURLArray()
} }
return $localizedURLs; return $localizedURLs;
} }
function get_domain($host)
{
$myhost = strtolower(trim($host));
$count = substr_count($myhost, '.');
if ($count === 2) {
if (strlen(explode('.', $myhost)[1]) > 3) {
$myhost = explode('.', $myhost, 2)[1];
}
} else if ($count > 2) {
$myhost = get_domain(explode('.', $myhost, 2)[1]);
}
return $myhost;
}

View File

@ -16,17 +16,6 @@ use Illuminate\Support\Facades\Route;
$base_domain = config('app.url'); $base_domain = config('app.url');
$alias_domain = config('app.alias_url'); $alias_domain = config('app.alias_url');
function get_domain($host){
$myhost = strtolower(trim($host));
$count = substr_count($myhost, '.');
if($count === 2){
if(strlen(explode('.', $myhost)[1]) > 3) $myhost = explode('.', $myhost, 2)[1];
} else if($count > 2){
$myhost = get_domain(explode('.', $myhost, 2)[1]);
}
return $myhost;
}
Route::group([ Route::group([
'domain' => 'doi.' . get_domain($base_domain), 'domain' => 'doi.' . get_domain($base_domain),
'as' => 'doi' 'as' => 'doi'