MediaWiki master
ApiQueryGeneratorBase.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Api;
10
16abstract class ApiQueryGeneratorBase extends ApiQueryBase {
17
19 private $mGeneratorPageSet = null;
20
28 public function setGeneratorMode( ApiPageSet $generatorPageSet ) {
29 $this->mGeneratorPageSet = $generatorPageSet;
30 }
31
37 public function isInGeneratorMode() {
38 return $this->mGeneratorPageSet !== null;
39 }
40
46 protected function getPageSet() {
47 return $this->mGeneratorPageSet ?? parent::getPageSet();
48 }
49
55 public function encodeParamName( $paramName ) {
56 if ( $this->mGeneratorPageSet !== null ) {
57 return 'g' . parent::encodeParamName( $paramName );
58 } else {
59 return parent::encodeParamName( $paramName );
60 }
61 }
62
68 protected function setContinueEnumParameter( $paramName, $paramValue ) {
69 if ( $this->mGeneratorPageSet !== null ) {
70 $this->getContinuationManager()->addGeneratorContinueParam( $this, $paramName, $paramValue );
71 } else {
72 parent::setContinueEnumParameter( $paramName, $paramValue );
73 }
74 }
75
77 protected function getHelpFlags() {
78 // Corresponding messages: api-help-flag-generator
79 $flags = parent::getHelpFlags();
80 $flags[] = 'generator';
81 return $flags;
82 }
83
88 abstract public function executeGenerator( $resultPageSet );
89}
90
92class_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.