本文整理汇总了PHP中ResourceLoader::addSource方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoader::addSource方法的具体用法?PHP ResourceLoader::addSource怎么用?PHP ResourceLoader::addSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceLoader
的用法示例。
在下文中一共展示了ResourceLoader::addSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerSources
protected static function registerSources(ResourceLoader $resourceLoader)
{
global $wgScriptPath, $wgScriptExtension, $wgMedusaHostPrefix, $wgCdnRootUrl, $wgDevelEnvironment, $wgStagingEnvironment, $wgCityId, $wgEnableResourceLoaderRewrites;
$sources = $resourceLoader->getSources();
// staff and internal special case
if ($wgCityId === null || $wgCityId === 11) {
$resourceLoader->addSource('common', $sources['local']);
return true;
}
// Determine the shared domain name
$isProduction = empty($wgDevelEnvironment) && empty($wgStagingEnvironment);
if ($isProduction) {
$host = 'http://' . (empty($wgMedusaHostPrefix) ? 'community.' : $wgMedusaHostPrefix) . 'wikia.com';
} else {
$host = $wgCdnRootUrl;
}
// Feed RL with the "common" source
$scriptUri = "{$host}{$wgScriptPath}/load{$wgScriptExtension}";
$apiUri = "{$host}{$wgScriptPath}/api{$wgScriptExtension}";
$sources['common'] = array('loadScript' => $scriptUri, 'apiScript' => $sources['local']['apiScript']);
if (!empty($wgEnableResourceLoaderRewrites)) {
// rewrite local source
$url = $sources['local']['loadScript'];
$url = str_replace("/load{$wgScriptExtension}", "/__load/-/", $url);
$sources['local']['loadScript'] = $url;
// rewrite common source
$url = $sources['common']['loadScript'];
$url = str_replace("/load{$wgScriptExtension}", "/__load/-/", $url);
if ($isProduction) {
$url = str_replace($host, $wgCdnRootUrl, $url);
}
$sources['common']['loadScript'] = $url;
}
$resourceLoader->setSource('local', $sources['local']);
$resourceLoader->addSource('common', $sources['common']);
return true;
}
示例2: testGetLoadScript
/**
* @covers ResourceLoader::getLoadScript
*/
public function testGetLoadScript()
{
$this->setMwGlobals('wgResourceLoaderSources', array());
$rl = new ResourceLoader();
$sources = self::fakeSources();
$rl->addSource($sources);
foreach (array('examplewiki', 'example2wiki') as $name) {
$this->assertEquals($rl->getLoadScript($name), $sources[$name]['loadScript']);
}
try {
$rl->getLoadScript('thiswasneverreigstered');
$this->assertTrue(false, 'ResourceLoader::getLoadScript should have thrown an exception');
} catch (MWException $e) {
$this->assertTrue(true);
}
}