本文整理汇总了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");
}
示例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);
}
}
示例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()));
}
示例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));
}
}
}
示例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;
}