本文整理汇总了PHP中ResourceLoader::getSources方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoader::getSources方法的具体用法?PHP ResourceLoader::getSources怎么用?PHP ResourceLoader::getSources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceLoader
的用法示例。
在下文中一共展示了ResourceLoader::getSources方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testAddSource
/**
* @dataProvider provideAddSource
* @covers ResourceLoader::addSource
* @covers ResourceLoader::getSources
*/
public function testAddSource($name, $info, $expected)
{
$rl = new ResourceLoader();
if ($expected === false) {
$this->setExpectedException('MWException', 'ResourceLoader duplicate source addition error');
$rl->addSource($name, $info);
}
$rl->addSource($name, $info);
if (is_array($expected)) {
foreach ($expected as $source) {
$this->assertArrayHasKey($source, $rl->getSources());
}
} else {
$this->assertArrayHasKey($expected, $rl->getSources());
}
}
示例3: testAddSource
/**
* @dataProvider provideAddSource
* @covers ResourceLoader::addSource
* @covers ResourceLoader::getSources
*/
public function testAddSource($name, $info, $expected)
{
$rl = new ResourceLoader();
$rl->addSource($name, $info);
if (is_array($expected)) {
foreach ($expected as $source) {
$this->assertArrayHasKey($source, $rl->getSources());
}
} else {
$this->assertArrayHasKey($expected, $rl->getSources());
}
}