MediaWiki master
ApiQueryGeneratorBase.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Api;
24
30abstract class ApiQueryGeneratorBase extends ApiQueryBase {
31
33 private $mGeneratorPageSet = null;
34
42 public function setGeneratorMode( ApiPageSet $generatorPageSet ) {
43 $this->mGeneratorPageSet = $generatorPageSet;
44 }
45
51 public function isInGeneratorMode() {
52 return $this->mGeneratorPageSet !== null;
53 }
54
60 protected function getPageSet() {
61 return $this->mGeneratorPageSet ?? parent::getPageSet();
62 }
63
69 public function encodeParamName( $paramName ) {
70 if ( $this->mGeneratorPageSet !== null ) {
71 return 'g' . parent::encodeParamName( $paramName );
72 } else {
73 return parent::encodeParamName( $paramName );
74 }
75 }
76
82 protected function setContinueEnumParameter( $paramName, $paramValue ) {
83 if ( $this->mGeneratorPageSet !== null ) {
84 $this->getContinuationManager()->addGeneratorContinueParam( $this, $paramName, $paramValue );
85 } else {
86 parent::setContinueEnumParameter( $paramName, $paramValue );
87 }
88 }
89
91 protected function getHelpFlags() {
92 // Corresponding messages: api-help-flag-generator
93 $flags = parent::getHelpFlags();
94 $flags[] = 'generator';
95 return $flags;
96 }
97
102 abstract public function executeGenerator( $resultPageSet );
103}
104
106class_alias( ApiQueryGeneratorBase::class, 'ApiQueryGeneratorBase' );
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.
executeGenerator( $resultPageSet)
Execute this module as a generator.
setGeneratorMode(ApiPageSet $generatorPageSet)
Switch this module to generator mode.
isInGeneratorMode()
Indicate whether the module is in generator mode.
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.