diff --git a/src/Core/GNUsocial.php b/src/Core/GNUsocial.php index c7e54b9e95..e4899145e5 100644 --- a/src/Core/GNUsocial.php +++ b/src/Core/GNUsocial.php @@ -171,7 +171,7 @@ class GNUsocial implements EventSubscriberInterface Form::setFactory($this->form_factory); Queue::setMessageBus($this->message_bus); Security::setHelper($this->security, $this->sanitizer); - Router::setRouter($this->router, $this->url_generator); + Router::setServices($this->router, $this->url_generator); HTTPClient::setClient($this->client); Formatting::setTwig($this->twig); Cache::setupCache(); diff --git a/src/Core/Router/Router.php b/src/Core/Router/Router.php index 13f67cc898..9276e94ea4 100644 --- a/src/Core/Router/Router.php +++ b/src/Core/Router/Router.php @@ -61,12 +61,22 @@ abstract class Router public static ?SRouter $router = null; public static ?UrlGeneratorInterface $url_gen = null; - public static function setRouter($rtr, $gen): void + public static function setServices($rtr, $gen): void { self::$router = $rtr; self::$url_gen = $gen; } + public static function isAbsolute(string $url) + { + return isset(parse_url($url)['host']); + } + + /** + * Generate a URL for route $id with $args replacing the + * placeholder route values. Extra params are added as query + * string to the URL + */ public static function url(string $id, array $args, int $type = self::ABSOLUTE_PATH): string { return self::$url_gen->generate($id, $args, $type);