An AMF gateway server implementation to allow the connection of the Adobe Flash Player to Zend Framework

todo Make the reflection methods cache and autoload.
package Zend_Amf
subpackage Server
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

The server constructor

__construct() 

Creates an array of directories in which services can reside.

addDirectory(string $dir) 

TODO: add support for prefixes?

Parameters

$dir

string

Attach a function to the server

addFunction(string|array $function, string $namespace = '') : \Zend_Amf_Server

Additional arguments to pass to the function at dispatch may be passed; any arguments following the namespace will be aggregated and passed at dispatch time.

inherited_from \Zend_Server_Interface::addFunction()

Parameters

$function

stringarray

Valid callback

$namespace

string

Optional namespace prefix

Exceptions

\Zend_Amf_Server_Exception

Returns

\Zend_Amf_Server

Raise a server fault

fault(string|\Exception $fault = null, integer $code = 404) : void

Unimplemented

inherited_from \Zend_Server_Interface::fault()

Parameters

$fault

string\Exception

$code

Get ACL adapter

getAcl() : \Zend_Acl

Returns

\Zend_Acl

Get authentication adapter

getAuth() : \Zend_Amf_Auth_Abstract

Returns

\Zend_Amf_Auth_Abstract

Returns an array of directories that can hold services.

getDirectory() : array

Returns

array

Returns a list of registered methods

getFunctions() : array

Returns an array of dispatchables (Zend_Server_Reflection_Function, _Method, and _Class items).

inherited_from \Zend_Server_Interface::getFunctions()

Returns

array

Return currently registered request object

getRequest() : null | \Zend_Amf_Request

Returns

null\Zend_Amf_Request

get a reference to the Zend_Amf_response instance

getResponse() : \Zend_Amf_Server_Response

Returns

\Zend_Amf_Server_Response

Handle an AMF call from the gateway.

handle(null|\Zend_Amf_Request $request = null) : \Zend_Amf_Response

Requests may be passed in, or the server may automagically determine the request based on defaults. Dispatches server request to appropriate method and returns a response

inherited_from \Zend_Server_Interface::handle()

Parameters

$request

null\Zend_Amf_Request

Optional

Returns

\Zend_Amf_Response

Whether or not the server is in production

isProduction() : boolean

Returns

boolean

Whether of not the server is using sessions

isSession() : boolean

Returns

boolean

List all available methods

listMethods() : array

Returns an array of method names.

Returns

array

Load server definition

loadFunctions(array $definition) : void

Unimplemented

inherited_from \Zend_Server_Interface::loadFunctions()

Parameters

$definition

array

Set ACL adapter

setAcl(\Zend_Acl $acl) : \Zend_Amf_Server

Parameters

$acl

\Zend_Acl

Returns

\Zend_Amf_Server

Set authentication adapter

setAuth(\Zend_Amf_Auth_Abstract $auth) : \Zend_Amf_Server

If the authentication adapter implements a "getAcl()" method, populate the ACL of this instance with it (if none exists already).

Parameters

$auth

\Zend_Amf_Auth_Abstract

Returns

\Zend_Amf_Server

Attach a class or object to the server

setClass(string|object $class, string $namespace = '', $argv = null) : \Zend_Amf_Server

Class may be either a class name or an instantiated object. Reflection is done on the class or object to determine the available public methods, and each is attached to the server as and available method. If a $namespace has been provided, that namespace is used to prefix AMF service call.

inherited_from \Zend_Server_Interface::setClass()

Parameters

$class

stringobject

$namespace

string

Optional

$argv

Exceptions

\Zend_Amf_Server_Exception on invalid input

Returns

\Zend_Amf_Server

Map ActionScript classes to PHP classes

setClassMap(string $asClass, string $phpClass) : \Zend_Amf_Server

Parameters

$asClass

string

$phpClass

string

Returns

\Zend_Amf_Server

Set server persistence

setPersistence(mixed $mode) : void

Unimplemented

inherited_from \Zend_Server_Interface::setPersistence()

Parameters

$mode

mixed

Set production flag

setProduction(boolean $flag) : \Zend_Amf_Server

Parameters

$flag

boolean

Returns

\Zend_Amf_Server

Set request object

setRequest(string|\Zend_Amf_Request $request) : \Zend_Amf_Server

Parameters

$request

string\Zend_Amf_Request

Returns

\Zend_Amf_Server

Public access method to private Zend_Amf_Server_Response reference

setResponse(string|\Zend_Amf_Server_Response $response) : \Zend_Amf_Server

Parameters

$response

string\Zend_Amf_Server_Response

Returns

\Zend_Amf_Server

setSession()

setSession($namespace = 'Zend_Amf') : \Zend_Amf_Server

Parameters

$namespace

Returns

\Zend_Amf_Server

(Re)Build the dispatch table

_buildDispatchTable() : void

The dispatch table consists of a an array of method name => Zend_Server_Reflection_Function_Abstract pairs

Cast parameters

_castParameters(\Reflection $reflectionMethod, array $params) : array

Takes the provided parameters from the request, and attempts to cast them to objects, if the prototype defines any as explicit object types

Parameters

$reflectionMethod

\Reflection

$params

array

Returns

array

Check if the ACL allows accessing the function or method

_checkAcl(string|object $object, string $function) : \unknown_type

Parameters

$object

stringobject

Object or class being accessed

$function

string

Function or method being accessed

Returns

\unknown_type

Loads a remote class or method and executes the function and returns the result

_dispatch(string $method, $params = null, $source = null) : mixed

Parameters

$method

string

Is the method to execute

$params

$source

Exceptions

\Zend_Amf_Server_Exception

Returns

mixed$response the result of executing the method

Create appropriate error message

_errorMessage(integer $objectEncoding, string $message, string $description, mixed $detail, integer $code, integer $line) : \Zend_Amf_Value_Messaging_ErrorMessage | array

Parameters

$objectEncoding

integer

Current AMF encoding

$message

string

Message that was being processed when error happened

$description

string

Error description

$detail

mixed

Detailed data about the error

$code

integer

Error code

$line

integer

Error line

Returns

\Zend_Amf_Value_Messaging_ErrorMessagearray

Takes the deserialized AMF request and performs any operations.

_handle(\Zend_Amf_Request $request) : \Zend_Amf_Response
todo should implement and SPL observer pattern for custom AMF headers
todo DescribeService support

Parameters

$request

\Zend_Amf_Request

Exceptions

\Zend_Amf_server_Exception\Exception

Returns

\Zend_Amf_Response

Handle AMF authentication

_handleAuth(string $userid, string $password) : boolean

Parameters

$userid

string

$password

string

Returns

boolean

Handles each of the 11 different command message types.

_loadCommandMessage(\Zend_Amf_Value_Messaging_CommandMessage $message) : \Zend_Amf_Value_Messaging_AcknowledgeMessage

A command message is a flex.messaging.messages.CommandMessage

see

Parameters

$message

\Zend_Amf_Value_Messaging_CommandMessage

Returns

\Zend_Amf_Value_Messaging_AcknowledgeMessage

Get PluginLoader for the Server

getLoader() : \Zend_Loader_PluginLoader

Returns

\Zend_Loader_PluginLoader

 Properties

 

ACL handler object

$_acl : \Zend_Acl

Default

 

Authentication handler object

$_auth : \Zend_Amf_Auth_Abstract

Default

 

Array of classes that can be called without being explicitly loaded

$_classAllowed : array

Default

array()

Keys are class names.

 

Loader for classes in added directories

$_loader : \Zend_Loader_PluginLoader

Default

 

Array of dispatchables

$_methods : array

Default

array()
 

Production flag; whether or not to return exception messages

$_production : boolean

Default

true
 

Request processed

$_request : null | \Zend_Amf_Request

Default

null
 

Class to use for responses

$_response : null | \Zend_Amf_Response

Default

 

Namespace allows all AMF calls to not clobber other PHP session variables

$_sesionNamespace : \Zend_Session_NameSpace

Default

'zend_amf'
 

session flag; whether or not to add a session to each response.

$_session : boolean

Default

false
 

Set the default session.name if php_

$_sessionName : string

Default

'PHPSESSID'
 

Dispatch table of name => method pairs

$_table : array

Default

array()