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


PHP ApiMain::getModuleManager方法代码示例

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


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

示例1: getInputs

    /**
     * @return string
     */
    private function getInputs()
    {
        global $wgEnableWriteAPI;
        $apiMain = new ApiMain(new FauxRequest(array()), $wgEnableWriteAPI);
        $this->apiQuery = new ApiQuery($apiMain, 'query');
        $formats = $apiMain->getModuleManager()->getNamesWithClasses('format');
        $formats = array_filter(array_keys($formats), 'SpecialApiSandbox::filterFormats');
        sort($formats);
        $formatOptions = array_combine($formats, $formats);
        $modules = array_keys($apiMain->getModuleManager()->getNamesWithClasses('action'));
        sort($modules);
        $key = array_search('query', $modules);
        if ($key !== false) {
            array_splice($modules, $key, 1);
            array_unshift($modules, 'query');
        }
        $moduleOptions = array_combine($modules, $modules);
        $queryModules = array_merge($this->getQueryModules('list'), $this->getQueryModules('prop'), $this->getQueryModules('meta'));
        $format = $this->msg('apisb-label-format')->escaped();
        $action = $this->msg('apisb-label-action')->escaped();
        $doc = $this->msg('apisb-label-doc')->escaped();
        $s = '
<table class="api-sandbox-options">
	<tbody>
		<tr>
			<th><label for="api-sandbox-format">' . $format . '</label></th>
			<th><label for="api-sandbox-action">' . $action . '</label></th>
			<th class="api-sandbox-docs-col">' . $doc . '</th>
		</tr>
		<tr>
			<td>' . $this->getSelect('format', $formatOptions, 'json') . '</td>
			<td>
				' . $this->getSelect('action', $moduleOptions) . '
				<div id="api-sandbox-query-row" style="display: none;">
					' . $this->getSelect('query', $queryModules) . '
				</div>
			</td>
			<td class="api-sandbox-docs-col">
				<div id="api-sandbox-buttons"></div>
				<div dir="ltr" id="api-sandbox-help"></div>
				<div id="api-sandbox-examples" style="display: none;" dir="ltr" class="mw-content-ltr"></div>
			</td>
		</tr>
	</tbody>
</table>
';
        $s .= '<div id="api-sandbox-main-inputs"></div>' . '<div id="api-sandbox-query-inputs" style="display: none"></div>' . $this->openFieldset('generic-parameters') . '<div id="api-sandbox-generic-inputs" class="mw-collapsible mw-collapsed"></div></fieldset>' . $this->openFieldset('generator-parameters', array('style' => 'display: none;')) . '<div id="api-sandbox-generator-inputs"></div></fieldset>
';
        return $s;
    }
开发者ID:aahashderuffy,项目名称:extensions,代码行数:53,代码来源:SpecialApiSandbox.php

示例2: encodeData

 /**
  * Get the formatter output for the given input data
  * @param array $params Query parameters
  * @param array $data Data to encode
  * @param string $class Printer class to use instead of the normal one
  * @return string
  * @throws Exception
  */
 protected function encodeData(array $params, array $data, $class = null)
 {
     $context = new RequestContext();
     $context->setRequest(new FauxRequest($params, true));
     $main = new ApiMain($context);
     if ($class !== null) {
         $main->getModuleManager()->addModule($this->printerName, 'format', $class);
     }
     $result = $main->getResult();
     $result->addArrayType(null, 'default');
     foreach ($data as $k => $v) {
         $result->addValue(null, $k, $v);
     }
     $printer = $main->createPrinterByName($this->printerName);
     $printer->initPrinter();
     $printer->execute();
     ob_start();
     try {
         $printer->closePrinter();
         return ob_get_clean();
     } catch (Exception $ex) {
         ob_end_clean();
         throw $ex;
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:33,代码来源:ApiFormatTestBase.php

示例3: testClassNamesInModuleManager

 /**
  * Test if all classes in the main module manager exists
  */
 public function testClassNamesInModuleManager()
 {
     global $wgAutoloadLocalClasses, $wgAutoloadClasses;
     // wgAutoloadLocalClasses has precedence, just like in includes/AutoLoader.php
     $classes = $wgAutoloadLocalClasses + $wgAutoloadClasses;
     $api = new ApiMain(new FauxRequest(array('action' => 'query', 'meta' => 'siteinfo')));
     $modules = $api->getModuleManager()->getNamesWithClasses();
     foreach ($modules as $name => $class) {
         $this->assertArrayHasKey($class, $classes, 'Class ' . $class . ' for api module ' . $name . ' not in autoloader (with exact case)');
     }
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:14,代码来源:ApiMainTest.php


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