Skip to content

Commit

Permalink
Merge pull request #7851 from Sesquipedalian/autoloader_hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Sesquipedalian authored Nov 6, 2023
2 parents fd263c8 + c356eb2 commit 323322e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Sources/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/
spl_autoload_register(function ($class)
{
static $level = 0;
static $hook_value = '';

$class_map = array(
static $class_map = array(
// Some special cases.
'ReCaptcha\\' => 'ReCaptcha/',
'MatthiasMullie\\Minify\\' => 'minify/src/',
Expand All @@ -40,19 +40,18 @@
$sourcedir = __DIR__;

// Do any third-party scripts want in on the fun?
if ($level === 0)
if (class_exists('SMF\\Config', false) && $hook_value !== (Config::$modSettings['integrate_autoload'] ?? ''))
{
$level++;

if (!class_exists('SMF\\IntegrationHook', false) && is_file($sourcedir . '/IntegrationHook.php'))
{
require $sourcedir . '/IntegrationHook.php';
require_once $sourcedir . '/IntegrationHook.php';
}

if (class_exists('SMF\\IntegrationHook', false))
{
$hook_value = Config::$modSettings['integrate_autoload'];
IntegrationHook::call('integrate_autoload', array(&$class_map));

$level--;
}
}

foreach ($class_map as $prefix => $dirname)
Expand Down

0 comments on commit 323322e

Please sign in to comment.