當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。