当前位置: 首页>>代码示例>>PHP>>正文


PHP ResourceLoader::getSources方法代码示例

本文整理汇总了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;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:37,代码来源:ResourceLoaderHooks.class.php

示例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());
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:21,代码来源:ResourceLoaderTest.php

示例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());
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:17,代码来源:ResourceLoaderTest.php


注:本文中的ResourceLoader::getSources方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。