mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-24 02:44:51 +03:00
Добавил ComponentHelper
This commit is contained in:
parent
a1e89a0463
commit
cf9d7d0889
@ -10,6 +10,7 @@ use Joomla\CMS\Extension\BootableExtensionInterface;
|
|||||||
use Joomla\CMS\Extension\MVCComponent;
|
use Joomla\CMS\Extension\MVCComponent;
|
||||||
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
|
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
use Webmasterskaya\Component\OauthServer\Administrator\Helper\ComponentHelper;
|
||||||
|
|
||||||
\defined('JPATH_PLATFORM') or die;
|
\defined('JPATH_PLATFORM') or die;
|
||||||
|
|
||||||
@ -32,22 +33,6 @@ class Component extends MVCComponent implements
|
|||||||
*/
|
*/
|
||||||
public function boot(ContainerInterface $container): void
|
public function boot(ContainerInterface $container): void
|
||||||
{
|
{
|
||||||
self::requireDependency();
|
ComponentHelper::registerComponentDependencies();
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
22
com_oauthserver/administrator/src/Helper/ComponentHelper.php
Normal file
22
com_oauthserver/administrator/src/Helper/ComponentHelper.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Webmasterskaya\Component\OauthServer\Administrator\Helper;
|
||||||
|
|
||||||
|
abstract class ComponentHelper
|
||||||
|
{
|
||||||
|
public static function registerComponentDependencies(): void
|
||||||
|
{
|
||||||
|
static $registered;
|
||||||
|
|
||||||
|
if (!isset($registered)) {
|
||||||
|
/** @var \Composer\Autoload\ClassLoader $loader */
|
||||||
|
$loader = require JPATH_LIBRARIES . '/lib_oauthserver/vendor/autoload.php';
|
||||||
|
|
||||||
|
$loader->unregister();
|
||||||
|
|
||||||
|
if (spl_autoload_register([new \Joomla\CMS\Autoload\ClassLoader($loader), 'loadClass'])) {
|
||||||
|
$registered = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user