[CORE][Router] Remove duplicate service for URL generation, as that is actually the same object

This commit is contained in:
Hugo Sales 2021-11-10 13:59:02 +00:00
parent 420ebcda26
commit dea9aa4dcf
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 5 additions and 11 deletions

View File

@ -70,7 +70,6 @@ use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Security as SSecurity;
use Symfony\Component\Security\Http\Util\TargetPathTrait;
@ -92,7 +91,6 @@ class GNUsocial implements EventSubscriberInterface
protected TranslatorInterface $translator;
protected EntityManagerInterface $entity_manager;
protected RouterInterface $router;
protected UrlGeneratorInterface $url_generator;
protected FormFactoryInterface $form_factory;
protected MessageBusInterface $message_bus;
protected EventDispatcherInterface $event_dispatcher;
@ -116,7 +114,6 @@ class GNUsocial implements EventSubscriberInterface
TranslatorInterface $trans,
EntityManagerInterface $em,
RouterInterface $router,
UrlGeneratorInterface $url_gen,
FormFactoryInterface $ff,
MessageBusInterface $mb,
EventDispatcherInterface $ed,
@ -136,7 +133,6 @@ class GNUsocial implements EventSubscriberInterface
$this->translator = $trans;
$this->entity_manager = $em;
$this->router = $router;
$this->url_generator = $url_gen;
$this->form_factory = $ff;
$this->message_bus = $mb;
$this->event_dispatcher = $ed;
@ -174,7 +170,7 @@ class GNUsocial implements EventSubscriberInterface
Form::setFactory($this->form_factory);
Queue::setMessageBus($this->message_bus);
Security::setHelper($this->security, $this->sanitizer);
Router::setServices($this->router, $this->url_generator);
Router::setRouter($this->router);
HTTPClient::setClient($this->client);
Formatting::setTwig($this->twig);
Cache::setupCache();

View File

@ -63,13 +63,11 @@ abstract class Router
*/
public const NETWORK_PATH = UrlGeneratorInterface::NETWORK_PATH;
public static ?SymfonyRouter $router = null;
public static ?UrlGeneratorInterface $url_gen = null;
public static ?SymfonyRouter $router = null;
public static function setServices($rtr, $gen): void
public static function setRouter($rtr): void
{
self::$router = $rtr;
self::$url_gen = $gen;
self::$router = $rtr;
}
public static function isAbsolute(string $url)
@ -84,7 +82,7 @@ abstract class Router
*/
public static function url(string $id, array $args = [], int $type = self::ABSOLUTE_PATH): string
{
return self::$url_gen->generate($id, $args, $type);
return self::$router->generate($id, $args, $type);
}
/**