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


PHP ResourceLoader::getModuleNames方法代码示例

本文整理汇总了PHP中ResourceLoader::getModuleNames方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoader::getModuleNames方法的具体用法?PHP ResourceLoader::getModuleNames怎么用?PHP ResourceLoader::getModuleNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ResourceLoader的用法示例。


在下文中一共展示了ResourceLoader::getModuleNames方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     $rl = new ResourceLoader(ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $moduleNames = $rl->getModuleNames();
     $moduleList = implode(', ', array_map(array($dbw, 'addQuotes'), $moduleNames));
     $limit = max(1, intval($this->getOption('batchsize', 500)));
     $this->output("Cleaning up module_deps table...\n");
     $i = 1;
     $modDeps = $dbw->tableName('module_deps');
     do {
         // $dbw->delete() doesn't support LIMIT :(
         $where = $moduleList ? "md_module NOT IN ({$moduleList})" : '1=1';
         $dbw->query("DELETE FROM {$modDeps} WHERE {$where} LIMIT {$limit}", __METHOD__);
         $numRows = $dbw->affectedRows();
         $this->output("Batch {$i}: {$numRows} rows\n");
         $i++;
         wfWaitForSlaves();
     } while ($numRows > 0);
     $this->output("done\n");
     $this->output("Cleaning up msg_resource table...\n");
     $i = 1;
     $mrRes = $dbw->tableName('msg_resource');
     do {
         $where = $moduleList ? "mr_resource NOT IN ({$moduleList})" : '1=1';
         $dbw->query("DELETE FROM {$mrRes} WHERE {$where} LIMIT {$limit}", __METHOD__);
         $numRows = $dbw->affectedRows();
         $this->output("Batch {$i}: {$numRows} rows\n");
         $i++;
         wfWaitForSlaves();
     } while ($numRows > 0);
     $this->output("done\n");
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:33,代码来源:cleanupRemovedModules.php

示例2: execute

 public function execute()
 {
     $result = false;
     $resourceLoader = new ResourceLoader();
     foreach ($resourceLoader->getModuleNames() as $name) {
         /** @var ResourceLoaderFileModule $module */
         $module = $resourceLoader->getModule($name);
         if (!$module || !$module instanceof ResourceLoaderFileModule) {
             continue;
         }
         $hadErrors = false;
         foreach ($module->getAllStyleFiles() as $file) {
             if ($module->getStyleSheetLang($file) !== 'less') {
                 continue;
             }
             try {
                 $compiler = ResourceLoader::getLessCompiler();
                 $compiler->compileFile($file);
             } catch (Exception $e) {
                 if (!$hadErrors) {
                     $this->error("Errors checking module {$name}:\n");
                     $hadErrors = true;
                 }
                 $this->error($e->getMessage() . "\n");
                 $result = true;
             }
         }
     }
     if (!$result) {
         $this->output("No errors found\n");
     } else {
         die(1);
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:34,代码来源:checkLess.php

示例3: getAllModules

 /**
  * Get all registered modules from ResouceLoader.
  */
 protected static function getAllModules()
 {
     global $wgEnableJavaScriptTest;
     // Test existance of test suite files as well
     // (can't use setUp or setMwGlobals because providers are static)
     $org_wgEnableJavaScriptTest = $wgEnableJavaScriptTest;
     $wgEnableJavaScriptTest = true;
     // Initialize ResourceLoader
     $rl = new ResourceLoader();
     $modules = array();
     foreach ($rl->getModuleNames() as $moduleName) {
         $modules[$moduleName] = $rl->getModule($moduleName);
     }
     // Restore settings
     $wgEnableJavaScriptTest = $org_wgEnableJavaScriptTest;
     return array('modules' => $modules, 'resourceloader' => $rl, 'context' => new ResourceLoaderContext($rl, new FauxRequest()));
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:20,代码来源:ResourcesTest.php

示例4: __construct

 public function __construct()
 {
     parent::__construct();
     $resourceLoader = new ResourceLoader();
     foreach ($resourceLoader->getModuleNames() as $name) {
         $module = $resourceLoader->getModule($name);
         if (!$module || !$module instanceof ResourceLoaderFileModule) {
             continue;
         }
         foreach ($module->getAllStyleFiles() as $styleFile) {
             // TODO (phuedx, 2014-03-19) The
             // ResourceLoaderFileModule class shouldn't
             // know how to get a file's extension.
             if ($module->getStyleSheetLang($styleFile) !== 'less') {
                 continue;
             }
             $this->addTest(new LessFileCompilationTest($styleFile, $module));
         }
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:20,代码来源:LessTestSuite.php

示例5: provideResourceFiles

 /**
  * This ask the ResouceLoader for all registered files from modules
  * created by ResourceLoaderFileModule (or one of its descendants).
  *
  *
  * Since the raw data is stored in protected properties, we have to
  * overrride this through ReflectionObject methods.
  */
 public static function provideResourceFiles()
 {
     global $wgEnableJavaScriptTest;
     // Test existance of test suite files as well
     // (can't use setUp or setMwGlobals because providers are static)
     $live_wgEnableJavaScriptTest = $wgEnableJavaScriptTest;
     $wgEnableJavaScriptTest = true;
     // Array with arguments for the test function
     $cases = array();
     // Initialize ResourceLoader
     $rl = new ResourceLoader();
     // See also ResourceLoaderFileModule::__construct
     $filePathProps = array('lists' => array('scripts', 'debugScripts', 'loaderScripts', 'styles'), 'nested-lists' => array('languageScripts', 'skinScripts', 'skinStyles'));
     foreach ($rl->getModuleNames() as $moduleName) {
         $module = $rl->getModule($moduleName);
         if (!$module instanceof ResourceLoaderFileModule) {
             continue;
         }
         $reflectedModule = new ReflectionObject($module);
         $files = array();
         foreach ($filePathProps['lists'] as $propName) {
             $property = $reflectedModule->getProperty($propName);
             $property->setAccessible(true);
             $list = $property->getValue($module);
             foreach ($list as $key => $value) {
                 // 'scripts' are numeral arrays.
                 // 'styles' can be numeral or associative.
                 // In case of associative the key is the file path
                 // and the value is the 'media' attribute.
                 if (is_int($key)) {
                     $files[] = $value;
                 } else {
                     $files[] = $key;
                 }
             }
         }
         foreach ($filePathProps['nested-lists'] as $propName) {
             $property = $reflectedModule->getProperty($propName);
             $property->setAccessible(true);
             $lists = $property->getValue($module);
             foreach ($lists as $group => $list) {
                 foreach ($list as $key => $value) {
                     // We need the same filter as for 'lists',
                     // due to 'skinStyles'.
                     if (is_int($key)) {
                         $files[] = $value;
                     } else {
                         $files[] = $key;
                     }
                 }
             }
         }
         // Get method for resolving the paths to full paths
         $method = $reflectedModule->getMethod('getLocalPath');
         $method->setAccessible(true);
         // Populate cases
         foreach ($files as $file) {
             $cases[] = array($method->invoke($module, $file), $module->getName(), $file);
         }
     }
     // Restore settings
     $wgEnableJavaScriptTest = $live_wgEnableJavaScriptTest;
     return $cases;
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:72,代码来源:ResourcesTest.php


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