PHP Класс 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
Наследование: extends Piwik\Singleton
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$alreadyRegistered array of already registered plugins names

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
checkIfMethodIsAvailable ( ReflectionMethod $method ) : boolean

Приватные методы

Метод Описание
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

Описание методов

__construct() публичный Метод

public __construct ( )

buildApiActionName() публичный Метод

public buildApiActionName ( $pluginName, $apiAction )

call() публичный Метод

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)
Результат mixed | null

checkIfMethodIsAvailable() защищенный Метод

protected checkIfMethodIsAvailable ( ReflectionMethod $method ) : boolean
$method ReflectionMethod
Результат boolean

getCountRegisteredClasses() публичный Метод

Returns number of classes already loaded
public getCountRegisteredClasses ( ) : integer
Результат integer

getMetadata() публичный Метод

Returns array containing reflection meta data for all the loaded classes eg. number of parameters, method names, etc.
public getMetadata ( ) : array
Результат array

getModuleNameFromClassName() публичный Метод

Returns the 'moduleName' part of '\\Piwik\\Plugins\\moduleName\\API'
public getModuleNameFromClassName ( string $className ) : string
$className string "API"
Результат string "Referrers"

getParametersList() публичный Метод

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
Результат array Format array( 'testParameter' => null, // no default value 'life' => 42, // default value = 42 'date' => 'yesterday', );

isDeprecatedMethod() публичный Метод

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

isExistingApiAction() публичный Метод

public isExistingApiAction ( $pluginName, $apiAction )

registerClass() публичный Метод

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() публичный Метод

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

shouldHideAPIMethod() публичный Метод

public shouldHideAPIMethod ( $docComment ) : boolean
$docComment
Результат boolean

Описание свойств

$alreadyRegistered защищенное свойство

array of already registered plugins names
protected $alreadyRegistered