MediaWiki 1.42.1
ApiQueryGeneratorBase.php
Go to the documentation of this file.
1<?php
28abstract class ApiQueryGeneratorBase extends ApiQueryBase {
29
30 private $mGeneratorPageSet = null;
31
39 public function setGeneratorMode( ApiPageSet $generatorPageSet ) {
40 $this->mGeneratorPageSet = $generatorPageSet;
41 }
42
48 public function isInGeneratorMode() {
49 return $this->mGeneratorPageSet !== null;
50 }
51
57 protected function getPageSet() {
58 return $this->mGeneratorPageSet ?? parent::getPageSet();
59 }
60
66 public function encodeParamName( $paramName ) {
67 if ( $this->mGeneratorPageSet !== null ) {
68 return 'g' . parent::encodeParamName( $paramName );
69 } else {
70 return parent::encodeParamName( $paramName );
71 }
72 }
73
79 protected function setContinueEnumParameter( $paramName, $paramValue ) {
80 if ( $this->mGeneratorPageSet !== null ) {
81 $this->getContinuationManager()->addGeneratorContinueParam( $this, $paramName, $paramValue );
82 } else {
83 parent::setContinueEnumParameter( $paramName, $paramValue );
84 }
85 }
86
88 protected function getHelpFlags() {
89 // Corresponding messages: api-help-flag-generator
90 $flags = parent::getHelpFlags();
91 $flags[] = 'generator';
92 return $flags;
93 }
94
99 abstract public function executeGenerator( $resultPageSet );
100}
getContinuationManager()
Definition ApiBase.php:708
This class contains a list of pages that the client has requested.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
getPageSet()
Get the PageSet object to work on.
setGeneratorMode(ApiPageSet $generatorPageSet)
Switch this module to generator mode.
executeGenerator( $resultPageSet)
Execute this module as a generator.
getHelpFlags()
Generates the list of flags for the help screen and for action=paraminfo.Corresponding messages: api-...
encodeParamName( $paramName)
Overrides ApiBase to prepend 'g' to every generator parameter.
isInGeneratorMode()
Indicate whether the module is in generator mode.