/**
* Register core modules and runs registration hooks.
- * @param Config|null $config [optional]
+ * @param Config|null $config
* @param LoggerInterface|null $logger [optional]
*/
public function __construct( Config $config = null, LoggerInterface $logger = null ) {
$this->logger = $logger ?: new NullLogger();
if ( !$config ) {
- // TODO: Deprecate and remove.
- $this->logger->debug( __METHOD__ . ' was called without providing a Config instance' );
+ wfDeprecated( __METHOD__ . ' without a Config instance', '1.34' );
$config = MediaWikiServices::getInstance()->getMainConfig();
}
$this->config = $config;
// Special module that always exists
$this->register( 'startup', [ 'class' => ResourceLoaderStartUpModule::class ] );
- // Register extension modules
- $this->register( $config->get( 'ResourceModules' ) );
-
- // Avoid PHP 7.1 warning from passing $this by reference
- $rl = $this;
- Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
-
- if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
- $this->registerTestModules();
- }
-
$this->setMessageBlobStore( new MessageBlobStore( $this, $this->logger ) );
}
}
}
+ /**
+ * @internal For use by ServiceWiring only
+ */
public function registerTestModules() {
global $IP;
*/
public static function makeLoaderConditionalScript( $script ) {
// Adds a function to lazy-created RLQ
- return '(window.RLQ=window.RLQ||[]).push(function(){' .
+ return '(RLQ=window.RLQ||[]).push(function(){' .
trim( $script ) . '});';
}
*/
public static function makeInlineCodeWithModule( $modules, $script ) {
// Adds an array to lazy-created RLQ
- return '(window.RLQ=window.RLQ||[]).push(['
+ return '(RLQ=window.RLQ||[]).push(['
. self::encodeJsonForScript( $modules ) . ','
. 'function(){' . trim( $script ) . '}'
. ']);';
return new WrappedString(
Html::inlineScript( $js, $nonce ),
- "<script$escNonce>(window.RLQ=window.RLQ||[]).push(function(){",
+ "<script$escNonce>(RLQ=window.RLQ||[]).push(function(){",
'});</script>'
);
}