[FRAMEWORK] Avoid double initializing the framework

This commit is contained in:
Hugo Sales 2020-08-03 20:56:00 +00:00 committed by Hugo Sales
parent aac653d2bd
commit 152828ed68
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -67,6 +67,7 @@ class GNUsocial implements EventSubscriberInterface
{
use TargetPathTrait;
protected bool $initialized = false;
protected LoggerInterface $logger;
protected TranslatorInterface $translator;
protected EntityManagerInterface $entity_manager;
@ -92,7 +93,7 @@ class GNUsocial implements EventSubscriberInterface
SessionInterface $sess,
SSecurity $sec,
MailerInterface $mail,
ModuleManager $mod)
ModuleManager $mm)
{
$this->logger = $logger;
$this->translator = $trans;
@ -104,7 +105,7 @@ class GNUsocial implements EventSubscriberInterface
$this->session = $sess;
$this->security = $sec;
$this->mailer = $mail;
$this->module_manager = $mod;
$this->module_manager = $mm;
$this->initialize();
}
@ -116,11 +117,11 @@ class GNUsocial implements EventSubscriberInterface
*/
public function initialize(): void
{
if (!$this->initialized) {
Log::setLogger($this->logger);
Event::setDispatcher($this->event_dispatcher);
I18n::setTranslator($this->translator);
DB::setManager($this->entity_manager);
Router::setRouter($this->router);
Form::setFactory($this->form_factory);
Queue::setMessageBus($this->message_bus);
Security::setHelper($this->security);
@ -130,7 +131,13 @@ class GNUsocial implements EventSubscriberInterface
Cache::setupCache();
// Events are proloaded on compilation, but set at runtime
$this->module_manager->loadModules();
Router::setRouter($this->router);
$this->initialized = true;
}
}
/**