From cf9d7d088931492df5c12d475892b2445bd11856 Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Fri, 8 Mar 2024 14:34:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20Co?= =?UTF-8?q?mponentHelper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../administrator/src/Extension/Component.php | 19 ++-------------- .../src/Helper/ComponentHelper.php | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 com_oauthserver/administrator/src/Helper/ComponentHelper.php diff --git a/com_oauthserver/administrator/src/Extension/Component.php b/com_oauthserver/administrator/src/Extension/Component.php index d2c119a..cd83844 100644 --- a/com_oauthserver/administrator/src/Extension/Component.php +++ b/com_oauthserver/administrator/src/Extension/Component.php @@ -10,6 +10,7 @@ use Joomla\CMS\Extension\BootableExtensionInterface; use Joomla\CMS\Extension\MVCComponent; use Joomla\CMS\HTML\HTMLRegistryAwareTrait; use Psr\Container\ContainerInterface; +use Webmasterskaya\Component\OauthServer\Administrator\Helper\ComponentHelper; \defined('JPATH_PLATFORM') or die; @@ -32,22 +33,6 @@ class Component extends MVCComponent implements */ public function boot(ContainerInterface $container): void { - self::requireDependency(); - } - - public static function requireDependency(): void - { - static $required; - - if (!isset($required)) { - /** @var \Composer\Autoload\ClassLoader $loader */ - $loader = require JPATH_LIBRARIES . '/lib_oauthserver/vendor/autoload.php'; - - $loader->unregister(); - - spl_autoload_register([new \Joomla\CMS\Autoload\ClassLoader($loader), 'loadClass'], true, true); - - $required = true; - } + ComponentHelper::registerComponentDependencies(); } } \ No newline at end of file diff --git a/com_oauthserver/administrator/src/Helper/ComponentHelper.php b/com_oauthserver/administrator/src/Helper/ComponentHelper.php new file mode 100644 index 0000000..40ff66f --- /dev/null +++ b/com_oauthserver/administrator/src/Helper/ComponentHelper.php @@ -0,0 +1,22 @@ +unregister(); + + if (spl_autoload_register([new \Joomla\CMS\Autoload\ClassLoader($loader), 'loadClass'])) { + $registered = true; + } + } + } +} \ No newline at end of file