aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-07-03 11:58:04 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-07-03 11:58:04 +0200
commit380e9c2ef448e478acddd1d8c70affe8356e4465 (patch)
treefc9b11562245089ba24a3c8e251f3250f5c7f13a
parent107693ff581970d5d0a147cdd02b1171fc45ff8a (diff)
parent520f3b3bd636b52608d134750464daf1b7a27493 (diff)
downloadforums-380e9c2ef448e478acddd1d8c70affe8356e4465.tar
forums-380e9c2ef448e478acddd1d8c70affe8356e4465.tar.gz
forums-380e9c2ef448e478acddd1d8c70affe8356e4465.tar.bz2
forums-380e9c2ef448e478acddd1d8c70affe8356e4465.tar.xz
forums-380e9c2ef448e478acddd1d8c70affe8356e4465.zip
Merge pull request #2674 from Nicofuma/ticket/12784
[ticket/12784] Allow the extensions to add a custom auto loader * Nicofuma/ticket/12784: [ticket/12784] Shearch the "vendor" folders and then the autoload.php files [ticket/12784] Allow the extensions to add a custom auto loader
-rw-r--r--phpBB/common.php2
-rw-r--r--phpBB/download/file.php2
-rw-r--r--phpBB/includes/functions.php31
3 files changed, 35 insertions, 0 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 4b06cd1eda..e96a34938a 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -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->register();
+phpbb_load_extensions_autoloaders($phpbb_root_path);
+
// Set up container
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index ce2855473b..f7636b0e1a 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -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->register();
+ phpbb_load_extensions_autoloaders($phpbb_root_path);
+
// Set up container
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 32acb0c9ff..0838f2008e 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -21,6 +21,37 @@ if (!defined('IN_PHPBB'))
// 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(2);
+
+ foreach ($iterator as $file_info)
+ {
+ if ($file_info->getFilename() === 'vendor' && $iterator->getDepth() === 2)
+ {
+ $filename = $file_info->getRealPath() . '/autoload.php';
+ if (file_exists($filename))
+ {
+ require $filename;
+ }
+ }
+ }
+}
+
+/**
* Casts a variable to the given type.
*
* @deprecated