Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Amf_Server Class Reference

Public Member Functions

 __construct ()
 The server constructor.
 
 setAuth (Zend_Amf_Auth_Abstract $auth)
 Set authentication adapter.
 
 getAuth ()
 Get authentication adapter.
 
 setAcl (Zend_Acl $acl)
 Set ACL adapter.
 
 getAcl ()
 Get ACL adapter.
 
 setProduction ($flag)
 Set production flag.
 
 isProduction ()
 Whether or not the server is in production.
 
 setSession ($namespace= 'Zend_Amf')
 
 isSession ()
 Whether of not the server is using sessions.
 
 handle ($request=null)
 Handle an AMF call from the gateway.
 
 setRequest ($request)
 Set request object.
 
 getRequest ()
 Return currently registered request object.
 
 setResponse ($response)
 Public access method to private Zend_Amf_Server_Response reference.
 
 getResponse ()
 get a reference to the Zend_Amf_response instance
 
 setClass ($class, $namespace= '', $argv=null)
 Attach a class or object to the server.
 
 addFunction ($function, $namespace= '')
 Attach a function to the server.
 
 addDirectory ($dir)
 Creates an array of directories in which services can reside.
 
 getDirectory ()
 Returns an array of directories that can hold services.
 
 fault ($fault=null, $code=404)
 Raise a server fault.
 
 getFunctions ()
 Returns a list of registered methods.
 
 setPersistence ($mode)
 Set server persistence.
 
 loadFunctions ($definition)
 Load server definition.
 
 setClassMap ($asClass, $phpClass)
 Map ActionScript classes to PHP classes.
 
 listMethods ()
 List all available methods.
 

Protected Member Functions

 _checkAcl ($object, $function)
 Check if the ACL allows accessing the function or method.
 
 getLoader ()
 Get PluginLoader for the Server.
 
 _dispatch ($method, $params=null, $source=null)
 Loads a remote class or method and executes the function and returns the result.
 
 _loadCommandMessage (Zend_Amf_Value_Messaging_CommandMessage $message)
 Handles each of the 11 different command message types.
 
 _errorMessage ($objectEncoding, $message, $description, $detail, $code, $line)
 Create appropriate error message.
 
 _handleAuth ($userid, $password)
 Handle AMF authentication.
 
 _handle (Zend_Amf_Request $request)
 Takes the deserialized AMF request and performs any operations.
 
 _buildDispatchTable ()
 (Re)Build the dispatch table
 
 _castParameters ($reflectionMethod, array $params)
 Cast parameters.
 

Protected Attributes

 $_methods = array()
 
 $_classAllowed = array()
 
 $_loader
 
 $_production = true
 
 $_request = null
 
 $_response
 
 $_table = array()
 
 $_session = false
 
 $_sesionNamespace = 'zend_amf'
 
 $_sessionName = 'PHPSESSID'
 
 $_auth
 
 $_acl
 

Constructor & Destructor Documentation

__construct ( )

The server constructor.

Member Function Documentation

_buildDispatchTable ( )
protected

(Re)Build the dispatch table

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

Returns
void
_castParameters (   $reflectionMethod,
array  $params 
)
protected

Cast parameters.

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

Parameters
Reflection$reflectionMethod
array$params
Returns
array
_checkAcl (   $object,
  $function 
)
protected

Check if the ACL allows accessing the function or method.

Parameters
string | object$objectObject or class being accessed
string$functionFunction or method being accessed
Returns
unknown_type
_dispatch (   $method,
  $params = null,
  $source = null 
)
protected

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

Parameters
string$methodIs the method to execute
mixed$paramvalues for the method
Returns
mixed $response the result of executing the method
Exceptions
Zend_Amf_Server_Exception
_errorMessage (   $objectEncoding,
  $message,
  $description,
  $detail,
  $code,
  $line 
)
protected

Create appropriate error message.

Parameters
int$objectEncodingCurrent AMF encoding
string$messageMessage that was being processed when error happened
string$descriptionError description
mixed$detailDetailed data about the error
int$codeError code
int$lineError line
Returns
Zend_Amf_Value_Messaging_ErrorMessage|array
_handle ( Zend_Amf_Request  $request)
protected

Takes the deserialized AMF request and performs any operations.

Todo:

should implement and SPL observer pattern for custom AMF headers

DescribeService support

Parameters
Zend_Amf_Request$request
Returns
Zend_Amf_Response
Exceptions
Zend_Amf_server_Exception|Exception
_handleAuth (   $userid,
  $password 
)
protected

Handle AMF authentication.

Parameters
string$userid
string$password
Returns
boolean
_loadCommandMessage ( Zend_Amf_Value_Messaging_CommandMessage  $message)
protected

Handles each of the 11 different command message types.

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

See Also
Zend_Amf_Value_Messaging_CommandMessage
Parameters
Zend_Amf_Value_Messaging_CommandMessage$message
Returns
Zend_Amf_Value_Messaging_AcknowledgeMessage
addDirectory (   $dir)

Creates an array of directories in which services can reside.

TODO: add support for prefixes?

Parameters
string$dir
addFunction (   $function,
  $namespace = '' 
)

Attach a function to the 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.

Parameters
string | array$functionValid callback
string$namespaceOptional namespace prefix
Returns
Zend_Amf_Server
Exceptions
Zend_Amf_Server_Exception

Implements Zend_Server_Interface.

fault (   $fault = null,
  $code = 404 
)

Raise a server fault.

Unimplemented

Parameters
string | Exception$fault
Returns
void

Implements Zend_Server_Interface.

getAcl ( )

Get ACL adapter.

Returns
Zend_Acl
getAuth ( )

Get authentication adapter.

Returns
Zend_Amf_Auth_Abstract
getDirectory ( )

Returns an array of directories that can hold services.

Returns
array
getFunctions ( )

Returns a list of registered methods.

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

Returns
array

Implements Zend_Server_Interface.

getLoader ( )
protected

Get PluginLoader for the Server.

Returns
Zend_Loader_PluginLoader
getRequest ( )

Return currently registered request object.

Returns
null|Zend_Amf_Request
getResponse ( )

get a reference to the Zend_Amf_response instance

Returns
Zend_Amf_Server_Response
handle (   $request = null)

Handle an AMF call from the gateway.

Parameters
null | Zend_Amf_Request$requestOptional
Returns
Zend_Amf_Response

Implements Zend_Server_Interface.

isProduction ( )

Whether or not the server is in production.

Returns
bool
isSession ( )

Whether of not the server is using sessions.

Returns
bool
listMethods ( )

List all available methods.

Returns an array of method names.

Returns
array
loadFunctions (   $definition)

Load server definition.

Unimplemented

Parameters
array$definition
Returns
void

Implements Zend_Server_Interface.

setAcl ( Zend_Acl  $acl)

Set ACL adapter.

Parameters
Zend_Acl$acl
Returns
Zend_Amf_Server
setAuth ( Zend_Amf_Auth_Abstract  $auth)

Set authentication adapter.

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

Parameters
Zend_Amf_Auth_Abstract$auth
Returns
Zend_Amf_Server
setClass (   $class,
  $namespace = '',
  $argv = null 
)

Attach a class or object to the 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.

Parameters
string | object$class
string$namespaceOptional
mixed$argOptional arguments to pass to a method
Returns
Zend_Amf_Server
Exceptions
Zend_Amf_Server_Exceptionon invalid input

Implements Zend_Server_Interface.

setClassMap (   $asClass,
  $phpClass 
)

Map ActionScript classes to PHP classes.

Parameters
string$asClass
string$phpClass
Returns
Zend_Amf_Server
setPersistence (   $mode)

Set server persistence.

Unimplemented

Parameters
mixed$mode
Returns
void

Implements Zend_Server_Interface.

setProduction (   $flag)

Set production flag.

Parameters
bool$flag
Returns
Zend_Amf_Server
setRequest (   $request)

Set request object.

Parameters
string | Zend_Amf_Request$request
Returns
Zend_Amf_Server
setResponse (   $response)

Public access method to private Zend_Amf_Server_Response reference.

Parameters
string | Zend_Amf_Server_Response$response
Returns
Zend_Amf_Server
setSession (   $namespace = 'Zend_Amf')
Parameters
namespaceof all incoming sessions defaults to Zend_Amf
Returns
Zend_Amf_Server

Member Data Documentation

$_acl
protected
$_auth
protected
$_classAllowed = array()
protected
$_loader
protected
$_methods = array()
protected
$_production = true
protected
$_request = null
protected
$_response
protected
$_sesionNamespace = 'zend_amf'
protected
$_session = false
protected
$_sessionName = 'PHPSESSID'
protected
$_table = array()
protected