PHP Class Amfphp_Core_Common_ServiceRouter, amfphp-2.0

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.
Author: Ariel Sommeria-klein
显示文件 Open project: silexlabs/amfphp-2.0 Class Usage Examples

Public Properties

Property Type Description
$checkArgumentCount boolean check parameters. This is useful for development, but should be disabled for production
$serviceFolders paths to folders containing services(relative or absolute)
$serviceNames2ClassFindInfo of ClassFindInfo

Public Methods

Method Description
__construct ( array $serviceFolders, array $serviceNames2ClassFindInfo, boolean $checkArgumentCount = false ) constructor
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.
getServiceObject ( String $serviceName ) : Object get service object
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.

Method Details

__construct() public method

constructor
public __construct ( array $serviceFolders, array $serviceNames2ClassFindInfo, boolean $checkArgumentCount = false )
$serviceFolders array folders containing service classes
$serviceNames2ClassFindInfo array a dictionary of service classes represented in a ClassFindInfo.
$checkArgumentCount boolean

executeServiceCall() public method

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
public executeServiceCall ( string $serviceName, string $methodName, array $parameters ) : mixed
$serviceName string
$methodName string
$parameters array
return mixed the result of the function call

getServiceObject() public method

get service object
public getServiceObject ( String $serviceName ) : Object
$serviceName String
return Object service object

getServiceObjectStatically() public static method

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
public static getServiceObjectStatically ( type $serviceName, array $serviceFolders, array $serviceNames2ClassFindInfo ) : Object
$serviceName type
$serviceFolders array
$serviceNames2ClassFindInfo array
return Object service object

Property Details

$checkArgumentCount public_oe property

check parameters. This is useful for development, but should be disabled for production
public bool $checkArgumentCount
return boolean

$serviceFolders public_oe property

paths to folders containing services(relative or absolute)
public $serviceFolders

$serviceNames2ClassFindInfo public_oe property

of ClassFindInfo
public $serviceNames2ClassFindInfo