Skip to content

Commit

Permalink
=
Browse files Browse the repository at this point in the history
  • Loading branch information
Arikaim committed Aug 4, 2022
1 parent 407bb75 commit 06c6cc4
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions RouteType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ class RouteType

/**
* Get route type
*
* @param string $path
* @param array $options
* @return int
*/
public static function getType(string $url): int
public static function getType(string $url, array $options = []): int
{
$url = \rtrim(\str_replace(BASE_PATH,'',$url),'/');
$segments = \explode('/',$url);
Expand All @@ -36,6 +40,7 @@ public static function getType(string $url): int
$segments[1] = $segments[1] ?? '';
$segments[2] = $segments[2] ?? '';
$segments[3] = $segments[3] ?? '';
$adminPagePath = $options['adminPagePath'] ?? 'admin';

if ($segments[1] == 'core' && $segments[2] == 'api') {
return Self::SYSTEM_API_URL;
Expand All @@ -47,7 +52,7 @@ public static function getType(string $url): int
}

// check for admin
if (($segments[1] == 'admin') && ($count <= 3)) {
if (($segments[1] == $adminPagePath) && ($count <= 3)) {
return Self::ADMIN_PAGE_URL;
}

Expand Down Expand Up @@ -83,22 +88,7 @@ public static function isLanguageSegment(array $urlSegments): bool
*/
public static function isSystemApiUrl(string $url): bool
{
$path = \str_replace(BASE_PATH,'',$url);

return (\substr($path,0,10) == '/core/api/');
}

/**
* Return true if request url is admin page
*
* @param string $url
* @return boolean
*/
public static function isAdminPage(string $url): bool
{
$path = \str_replace(BASE_PATH,'',$url);

return (\substr($path,0,6) == '/admin');
return (\substr(\str_replace(BASE_PATH,'',$url),0,10) == '/core/api/');
}

/**
Expand All @@ -110,9 +100,8 @@ public static function isAdminPage(string $url): bool
public static function isApiInstallRequest(?string $uri = null): bool
{
$uri = $uri ?? $_SERVER['REQUEST_URI'] ?? '';
$path = \str_replace(BASE_PATH,'',$uri);

return (\substr($path,0,18) == '/core/api/install/');
return (\substr(\str_replace(BASE_PATH,'',$uri),0,18) == '/core/api/install/');
}

/**
Expand Down

0 comments on commit 06c6cc4

Please sign in to comment.