mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 22:40:39 +02:00
[ticket/12784] Allow the extensions to add a custom auto loader
PHPBB3-12784
This commit is contained in:
@@ -95,6 +95,8 @@ $phpbb_class_loader->register();
|
|||||||
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
|
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
|
||||||
$phpbb_class_loader_ext->register();
|
$phpbb_class_loader_ext->register();
|
||||||
|
|
||||||
|
phpbb_load_extensions_autoloaders($phpbb_root_path);
|
||||||
|
|
||||||
// Set up container
|
// Set up container
|
||||||
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
||||||
|
|
||||||
|
@@ -59,6 +59,8 @@ if (isset($_GET['avatar']))
|
|||||||
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
|
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
|
||||||
$phpbb_class_loader_ext->register();
|
$phpbb_class_loader_ext->register();
|
||||||
|
|
||||||
|
phpbb_load_extensions_autoloaders($phpbb_root_path);
|
||||||
|
|
||||||
// Set up container
|
// Set up container
|
||||||
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
||||||
|
|
||||||
|
@@ -20,6 +20,33 @@ if (!defined('IN_PHPBB'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Common global functions
|
// Common global functions
|
||||||
|
/**
|
||||||
|
* Load the autoloaders added by the extensions.
|
||||||
|
*
|
||||||
|
* @param string $phpbb_root_path Path to the phpbb root directory.
|
||||||
|
*/
|
||||||
|
function phpbb_load_extensions_autoloaders($phpbb_root_path)
|
||||||
|
{
|
||||||
|
$iterator = new \RecursiveIteratorIterator(
|
||||||
|
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||||
|
new \RecursiveDirectoryIterator(
|
||||||
|
$phpbb_root_path . 'ext/',
|
||||||
|
\FilesystemIterator::SKIP_DOTS
|
||||||
|
)
|
||||||
|
),
|
||||||
|
\RecursiveIteratorIterator::SELF_FIRST
|
||||||
|
);
|
||||||
|
$iterator->setMaxDepth(3);
|
||||||
|
|
||||||
|
foreach ($iterator as $file_info)
|
||||||
|
{
|
||||||
|
if ($file_info->getFilename() === 'autoload.php' && $file_info->getPathInfo()->getFilename() === 'vendor')
|
||||||
|
{
|
||||||
|
require $file_info->getRealPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Casts a variable to the given type.
|
* Casts a variable to the given type.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user