Handleiding:ApiBase.php

This page is a translated version of the page Manual:ApiBase.php and the translation is 81% complete.

Die 'ApiBase klas' implementeer baie basiese API-funksies, en is die basis van alle API-klasse. Die klasfunksies word in verskillende funksiesareas verdeel:

  • Module parameters: Derived classes can define getAllowedParams() to specify which parameters to expect, how to parse and validate them.
  • Profiling: various methods to allow keeping tabs on various tasks and their time costs
  • Self-documentation: code to allow the API to document its own state

Funksies

getAllowedParams()

Spesifiseer watter parameters toegelaat word en watter vereistes daaraan gestel moet word. Kyk na die dokumentasie aan die bokant van includes/api/ApiBase.php vir die konstante PARAM_DFLT, PARAM_ISMULTI, PARAM_TYPE, PARAM_MAX, PARAM_MAX2, PARAM_MIN, PARAM_ALLOW_DUPLICATES, PARAM_DEPRECATED, PARAM_REQUIRED en PARAM_RANGE_ENFOR. Die moontlike tipes parameters is NULL, string, heelgetal, limiet, Boole, tydstempel, gebruiker of oplaai. 'N "Gebruiker" -parameter is 'n gebruikersnaam wat bekragtig word met Titel :: makeTitleSafe () . Vir Boole-parameters is 'n standaardwaarde van iets anders as 'onwaar' nie toegelaat nie.

Voorbeeld"

// Title parameter.
public function getAllowedParams() {
        return array(
                'title' => array (
                        ApiBase::PARAM_TYPE => 'string',
                        ApiBase::PARAM_REQUIRED => true
                ),
        );
}

getResultProperties() en getFinalResultProperties()

TODO:Beskryf wat hierdie dinge doen

getResult()

kry die API-resultaat (sien Manual:ApiResult.php ).

Hooks

Haken wat van heirdie lêer genoem word, word gelys in die Category:MediaWiki hooks included in ApiBase.php kategorie.

Sien ook