MediaWiki  master
ApiQueryGeneratorBase.php
Go to the documentation of this file.
1 <?php
28 abstract 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  if ( $this->mGeneratorPageSet !== null ) {
60  }
61 
62  return parent::getPageSet();
63  }
64 
70  public function encodeParamName( $paramName ) {
71  if ( $this->mGeneratorPageSet !== null ) {
72  return 'g' . parent::encodeParamName( $paramName );
73  } else {
74  return parent::encodeParamName( $paramName );
75  }
76  }
77 
83  protected function setContinueEnumParameter( $paramName, $paramValue ) {
84  if ( $this->mGeneratorPageSet !== null ) {
85  $this->getContinuationManager()->addGeneratorContinueParam( $this, $paramName, $paramValue );
86  } else {
87  parent::setContinueEnumParameter( $paramName, $paramValue );
88  }
89  }
90 
92  protected function getHelpFlags() {
93  // Corresponding messages: api-help-flag-generator
94  $flags = parent::getHelpFlags();
95  $flags[] = 'generator';
96  return $flags;
97  }
98 
103  abstract public function executeGenerator( $resultPageSet );
104 }
ApiQueryGeneratorBase\encodeParamName
encodeParamName( $paramName)
Overrides ApiBase to prepend 'g' to every generator parameter.
Definition: ApiQueryGeneratorBase.php:70
ApiQueryGeneratorBase\$mGeneratorPageSet
$mGeneratorPageSet
Definition: ApiQueryGeneratorBase.php:30
ApiQueryGeneratorBase\executeGenerator
executeGenerator( $resultPageSet)
Execute this module as a generator.
ApiQueryGeneratorBase\setGeneratorMode
setGeneratorMode(ApiPageSet $generatorPageSet)
Switch this module to generator mode.
Definition: ApiQueryGeneratorBase.php:39
ApiPageSet
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:42
ApiQueryGeneratorBase\setContinueEnumParameter
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
Definition: ApiQueryGeneratorBase.php:83
ApiQueryGeneratorBase\isInGeneratorMode
isInGeneratorMode()
Indicate whether the module is in generator mode.
Definition: ApiQueryGeneratorBase.php:48
ApiQueryGeneratorBase\getPageSet
getPageSet()
Get the PageSet object to work on.
Definition: ApiQueryGeneratorBase.php:57
ApiQueryBase
This is a base class for all Query modules.
Definition: ApiQueryBase.php:37
ApiBase\getContinuationManager
getContinuationManager()
Get the continuation manager.
Definition: ApiBase.php:607
ApiQueryGeneratorBase
Stable to extend.
Definition: ApiQueryGeneratorBase.php:28
ApiQueryGeneratorBase\getHelpFlags
getHelpFlags()
Generates the list of flags for the help screen and for action=paraminfo.Corresponding messages: api-...
Definition: ApiQueryGeneratorBase.php:92