Sapphire Documentation

Sapphire\Router\Router::class

class Router


private string $request_path - Stores the Request Path URL

private bool $is_admin_panel - Stores if user is in the admin panel

private bool $is_auth_section - Stores if user is in the "auth section" /admin/login

private string $resource_type - Resource type (if its a page or image etc)

private array $pages - Array with pages


public function __construct() - Constructs class

public function IsAdminPanelRequest(): bool - Returns router state

public function IsAuthRequest(): bool - Returns router state

public function AddPage(string $path, string $view): void - Add router page to pages array

public function AddPluginPage(string $path, string $view, string $plugin_name, array $data): void - Add plugin page to pages array

public function GetCurrentResource(): RouterResource - Returns resource that is being currently show

public function Redirect(string $new_url): void - Redirects request to other url

public function Setup(): void - Setups router

public function CheckIfIsAuth(): bool - Checks if page is /admin/login