PHP Class Piwik\API\Proxy

Proxy receives all the API calls requests via call() and forwards them to the right object, with the parameters in the right order. It will also log the performance of API calls (time spent, parameter values, etc.) if logger available
Inheritance: extends Piwik\Singleton
Afficher le fichier Open project: piwik/piwik Class Usage Examples

Protected Properties

Свойство Type Description
$alreadyRegistered array of already registered plugins names

Méthodes publiques

Méthode Description
__construct ( )
buildApiActionName ( $pluginName, $apiAction )
call ( string $className, string $methodName, array $parametersRequest ) : mixed | null Will execute $className->$methodName($parametersValues) If any error is detected (wrong number of parameters, method not found, class not found, etc.) it will throw an exception
getCountRegisteredClasses ( ) : integer Returns number of classes already loaded
getMetadata ( ) : array Returns array containing reflection meta data for all the loaded classes eg. number of parameters, method names, etc.
getModuleNameFromClassName ( string $className ) : string Returns the 'moduleName' part of '\\Piwik\\Plugins\\moduleName\\API'
getParametersList ( string $class, string $name ) : array Returns the parameters names and default values for the method $name of the class $class
isDeprecatedMethod ( $class, $methodName ) Check if given method name is deprecated or not.
isExistingApiAction ( $pluginName, $apiAction )
registerClass ( string $className ) Registers the API information of a given module.
setHideIgnoredFunctions ( boolean $hideIgnoredFunctions ) Sets whether to hide '@ignore'd functions from method metadata or not.
shouldHideAPIMethod ( $docComment ) : boolean

Méthodes protégées

Méthode Description
checkIfMethodIsAvailable ( ReflectionMethod $method ) : boolean

Private Methods

Méthode Description
checkClassIsSingleton ( string $className ) Checks that the class is a Singleton (presence of the getInstance() method)
checkMethodExists ( string $className, string $methodName ) Checks that the method exists in the class
getRequestParametersArray ( array $requiredParameters, array $parametersRequest ) : array Returns an array containing the values of the parameters to pass to the method to call
includeApiFile ( string $fileName ) Includes the class API by looking up plugins/xxx/API.php
isMethodAvailable ( string $className, string $methodName ) : boolean Returns true if the method is found in the API of the given class name.
loadMethodMetadata ( string $class, ReflectionMethod $method )
setDocumentation ( ReflectionClass $rClass, string $className ) Will be displayed in the API page

Method Details

__construct() public méthode

public __construct ( )

buildApiActionName() public méthode

public buildApiActionName ( $pluginName, $apiAction )

call() public méthode

It also logs the API calls, with the parameters values, the returned value, the performance, etc. You can enable logging in config/global.ini.php (log_api_call)
public call ( string $className, string $methodName, array $parametersRequest ) : mixed | null
$className string The class name (eg. API)
$methodName string The method name
$parametersRequest array The parameters pairs (name=>value)
Résultat mixed | null

checkIfMethodIsAvailable() protected méthode

protected checkIfMethodIsAvailable ( ReflectionMethod $method ) : boolean
$method ReflectionMethod
Résultat boolean

getCountRegisteredClasses() public méthode

Returns number of classes already loaded
public getCountRegisteredClasses ( ) : integer
Résultat integer

getMetadata() public méthode

Returns array containing reflection meta data for all the loaded classes eg. number of parameters, method names, etc.
public getMetadata ( ) : array
Résultat array

getModuleNameFromClassName() public méthode

Returns the 'moduleName' part of '\\Piwik\\Plugins\\moduleName\\API'
public getModuleNameFromClassName ( string $className ) : string
$className string "API"
Résultat string "Referrers"

getParametersList() public méthode

Returns the parameters names and default values for the method $name of the class $class
public getParametersList ( string $class, string $name ) : array
$class string The class name
$name string The method name
Résultat array Format array( 'testParameter' => null, // no default value 'life' => 42, // default value = 42 'date' => 'yesterday', );

isDeprecatedMethod() public méthode

Check if given method name is deprecated or not.
public isDeprecatedMethod ( $class, $methodName )

isExistingApiAction() public méthode

public isExistingApiAction ( $pluginName, $apiAction )

registerClass() public méthode

The module to be registered must be - a singleton (providing a getInstance() method) - the API file must be located in plugins/ModuleName/API.php for example plugins/Referrers/API.php The method will introspect the methods, their parameters, etc.
public registerClass ( string $className )
$className string ModuleName eg. "API"

setHideIgnoredFunctions() public méthode

Sets whether to hide '@ignore'd functions from method metadata or not.
public setHideIgnoredFunctions ( boolean $hideIgnoredFunctions )
$hideIgnoredFunctions boolean

shouldHideAPIMethod() public méthode

public shouldHideAPIMethod ( $docComment ) : boolean
$docComment
Résultat boolean

Property Details

$alreadyRegistered protected_oe property

array of already registered plugins names
protected $alreadyRegistered