From 8aff473458ed28cfc019dd42ebae2b5c9ec981f0 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 2 Dec 2021 22:43:56 -0800 Subject: [PATCH] (REF) Mixins - Promote `MixinLoader` to tracked service-object --- CRM/Extension/Mapper.php | 2 +- CRM/Extension/System.php | 12 +++++++++--- Civi/Core/Container.php | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CRM/Extension/Mapper.php b/CRM/Extension/Mapper.php index f82b9c8285..7f56f176f2 100644 --- a/CRM/Extension/Mapper.php +++ b/CRM/Extension/Mapper.php @@ -538,7 +538,7 @@ class CRM_Extension_Mapper { } // FIXME: How can code so code wrong be so right? CRM_Extension_System::singleton()->getClassLoader()->refresh(); - \CRM_Extension_System::singleton()->applyMixins(TRUE); + CRM_Extension_System::singleton()->getMixinLoader()->run(TRUE); } /** diff --git a/CRM/Extension/System.php b/CRM/Extension/System.php index 863da23513..e27d93fe1d 100644 --- a/CRM/Extension/System.php +++ b/CRM/Extension/System.php @@ -26,6 +26,7 @@ class CRM_Extension_System { private $manager = NULL; private $browser = NULL; private $downloader = NULL; + private $mixinLoader = NULL; /** * @var CRM_Extension_ClassLoader @@ -243,9 +244,14 @@ class CRM_Extension_System { return $this->downloader; } - public function applyMixins($force = FALSE) { - $mixinLoader = new CRM_Extension_MixinLoader(); - $mixinLoader->run($force); + /** + * @return CRM_Extension_MixinLoader; + */ + public function getMixinLoader() { + if ($this->mixinLoader === NULL) { + $this->mixinLoader = new CRM_Extension_MixinLoader(); + } + return $this->mixinLoader; } /** diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index fed7cca6d1..d733b6ce04 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -608,7 +608,7 @@ class Container { \CRM_Utils_Hook::singleton(TRUE); \CRM_Extension_System::singleton(TRUE); \CRM_Extension_System::singleton()->getClassLoader()->register(); - \CRM_Extension_System::singleton()->applyMixins(); + \CRM_Extension_System::singleton()->getMixinLoader()->run(); $bootServices['dispatcher.boot']->setDispatchPolicy($mainDispatchPolicy); $runtime->includeCustomPath(); -- 2.25.1