'ParserTestFiles',
'AutoloadClasses',
'manifest_version',
+ 'load_composer_autoloader',
);
/**
$array[$name] = $value;
}
}
+
+ public function getExtraAutoloaderPaths( $dir, array $info ) {
+ $paths = array();
+ if ( isset( $info['load_composer_autoloader'] ) && $info['load_composer_autoloader'] === true ) {
+ $path = "$dir/vendor/autoload.php";
+ if ( file_exists( $path ) ) {
+ $paths[] = $path;
+ }
+ }
+ return $paths;
+ }
}
/**
* Bump whenever the registration cache needs resetting
*/
- const CACHE_VERSION = 1;
+ const CACHE_VERSION = 2;
/**
* Special key that defines the merge strategy
public function readFromQueue( array $queue ) {
global $wgVersion;
$autoloadClasses = array();
+ $autoloaderPaths = array();
$processor = new ExtensionProcessor();
$incompatible = array();
$coreVersionParser = new CoreVersionChecker( $wgVersion );
. '.';
continue;
}
+ // Get extra paths for later inclusion
+ $autoloaderPaths = array_merge( $autoloaderPaths,
+ $processor->getExtraAutoloaderPaths( dirname( $path ), $info ) );
// Compatible, read and extract info
$processor->extractInfo( $path, $info, $version );
}
}
$data['globals']['wgExtensionCredits'][self::MERGE_STRATEGY] = 'array_merge_recursive';
$data['autoload'] = $autoloadClasses;
+ $data['autoloaderPaths'] = $autoloaderPaths;
return $data;
}
call_user_func( $cb );
}
- $this->loaded += $info['credits'];
+ foreach ( $info['autoloaderPaths'] as $path ) {
+ require_once $path;
+ }
+ $this->loaded += $info['credits'];
if ( $info['attributes'] ) {
if ( !$this->attributes ) {
$this->attributes = $info['attributes'];
* like 'MediaWiki'. Values are a constraint string like "1.26.1".
*/
public function getRequirements( array $info );
+
+ /**
+ * Get the path for additional autoloaders, e.g. the one of Composer.
+ *
+ * @param string $dir
+ * @param array $info
+ * @return array Containing the paths for autoloader file(s).
+ * @since 1.27
+ */
+ public function getExtraAutoloaderPaths( $dir, array $info );
}