Class \Prado\Web\Services\TRpcApiProvider
TRpcApiProvider is an abstract class the can be subclasses in order to implement an api for a TRpcService. A subclass of TRpcApiProvider must implement the registerMethods method in order to declare the available methods, their names and the associated callback.
public function registerMethods()
{
return array(
'apiMethodName1' => array('method' => array($this, 'objectMethodName1')),
'apiMethodName2' => array('method' => array('ClassName', 'staticMethodName')),
);
}
In this example, two api method have been defined. The first refers to an object method that must be implemented in the same class, the second to a static method implemented in a 'ClassName' class. In both cases, the method implementation will receive the request parameters as its method parameters. Since the number of received parameters depends on external-supplied data, it's adviced to use php's func_get_args() funtion to validate them.
Providers must be registered in the service configuration in order to be available, as explained in TRpcService's documentation.
Class hierarchy
- \Prado\Web\Services\TRpcApiProvider
- \Prado\TModule implements IModule
- \Prado\TApplicationComponent
- \Prado\TComponent
Since: 3.2
public
|
__construct(TRpcServer $rpcServer) : mixed
Constructor: informs the rpc server of the registered methods
|
public
|
|
public
|
|
public
abstract
|
\Prado\TApplicationComponent::FX_CACHE_FILE, \Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |