本文整理汇总了PHP中ResourceLoader::setSource方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoader::setSource方法的具体用法?PHP ResourceLoader::setSource怎么用?PHP ResourceLoader::setSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceLoader
的用法示例。
在下文中一共展示了ResourceLoader::setSource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}