Jump to content

Manual:ApiBase.php

From mediawiki.org
This page is a translated version of the page Manual:ApiBase.php and the translation is 74% complete.

ApiBase sınıfı birçok temel API işlevini uygular ve tüm API sınıflarının temelidir. Sınıf işlevleri, çeşitli işlev alanlarına ayrılmıştır:

  • Modül parametreleri: Türetilmiş sınıflar, hangi parametrelerin bekleneceğini, bunların nasıl ayrıştırılacağını ve doğrulanacağını belirlemek için getAllowedParams() öğesini tanımlayabilir.
  • Profil oluşturma: çeşitli görevler ve zaman maliyetlerinde sekmelerin tutulmasına izin veren çeşitli yöntemler
  • Kendinden belgelendirme: API'nin kendi durumunu belgelemesine izin veren kod

İşlevler

getAllowedParams()

Hangi parametrelere izin verildiğini ve bunlara hangi gereksinimlerin uygulanacağını belirleyin. See the documentation at the top of includes/api/ApiBase.php for the constants PARAM_DFLT, PARAM_ISMULTI, PARAM_TYPE, PARAM_MAX, PARAM_MAX2, PARAM_MIN, PARAM_ALLOW_DUPLICATES, PARAM_DEPRECATED, PARAM_REQUIRED, PARAM_RANGE_ENFORCE. The possible types of parameters are NULL, string, integer, limit, boolean, timestamp, user, or upload. A "user" parameter is a username that is validated using Title::makeTitleSafe(). For boolean parameters, a default value of anything other than false is not allowed.

Örnek:

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

getResult()

API sonucunu alır (bkz Manual:ApiResult.php ).

Kancalar

Bu dosyadan çağrılan kancalar Category:MediaWiki hooks included in ApiBase.php kategorisinde listelenmiştir.

Notable changes

  • The class became namespaced (MediaWiki\Api\ApiBase) in MW 1.43. Extensions must update uses of this class accordingly.

Ayrıca bakınız