\Amfphp_Core_Common_ServiceRouter

The Service Router class is responsible for executing the remote service method and returning it's value.

based on the old 'Executive' of php 1.9. It looks for a service either explicitely defined in a ClassFindInfo object, or in a service folder.

Summary

Methods
Properties
Constants
__construct()
getServiceObjectStatically()
getServiceObject()
executeServiceCall()
$serviceFolders
$serviceNames2ClassFindInfo
$checkArgumentCount
FILTER_SERVICE_OBJECT
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

FILTER_SERVICE_OBJECT

FILTER_SERVICE_OBJECT

filter called when the service object is created. Useful for authentication

Properties

$serviceFolders

$serviceFolders : array

paths to folders containing services(relative or absolute)

Type

array — of paths

$serviceNames2ClassFindInfo

$serviceNames2ClassFindInfo : array

Type

array — of ClassFindInfo

$checkArgumentCount

$checkArgumentCount : Boolean

check parameters. This is useful for development, but should be disabled for production

Type

Boolean

Methods

__construct()

__construct(array $serviceFolders, array $serviceNames2ClassFindInfo, Boolean $checkArgumentCount)

constructor

Parameters

array $serviceFolders

folders containing service classes

array $serviceNames2ClassFindInfo

a dictionary of service classes represented in a ClassFindInfo.

Boolean $checkArgumentCount

getServiceObjectStatically()

getServiceObjectStatically(\type $serviceName, array $serviceFolders, array $serviceNames2ClassFindInfo) : Object

get a service object by its name. Looks for a match in serviceNames2ClassFindInfo, then in the defined service folders.

If none found, an exception is thrown this method is static so that it can be used also by the discovery service '__' are replaced by '/' to help the client generator support packages without messing with folders and the like the service object can either be in the global namespace or in the namespace suggested by the name. For example a call to Sub1/Sub2/NamespaceTestService will load the PHP file in Sub1/Sub2/NamespaceTestService, and return an instance of either NamespaceTestService or Sub1\Sub2\NamespaceTestService

Parameters

\type $serviceName
array $serviceFolders
array $serviceNames2ClassFindInfo

Returns

Object —

service object

getServiceObject()

getServiceObject(String $serviceName) : Object

get service object

Parameters

String $serviceName

Returns

Object —

service object

executeServiceCall()

executeServiceCall(string $serviceName, string $methodName, array $parameters) : mixed

loads and instanciates a service class matching $serviceName, then calls the function defined by $methodName using $parameters as parameters throws an exception if service not found.

if the service exists but not the function, an exception is thrown by call_user_func_array. It is pretty explicit, so no further code was added

Parameters

string $serviceName
string $methodName
array $parameters

Returns

mixed —

the result of the function call