Amf/Server.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Amf
- Version
- $Id: Server.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Amf_Server
An AMF gateway server implementation to allow the connection of the Adobe Flash Player to Zend Framework
- Implements
- \Zend_Server_Interface
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Todo
- Make the reflection methods cache and autoload.
Properties


array $_classAllowed = array()
Array of classes that can be called without being explicitly loaded
Keys are class names.
array()
Details- Type
- array


bool $_production = true
true
Details- Type
- bool


null|\Zend_Amf_Request $_request = null
Request processed
null
Details- Type
- null | \Zend_Amf_Request


null|\Zend_Amf_Response $_response =
Class to use for responses
- Type
- null | \Zend_Amf_Response


\Zend_Session_NameSpace $_sesionNamespace = 'zend_amf'
Namespace allows all AMF calls to not clobber other PHP session variables
<p>default session namespace zend_amf</p>'zend_amf'
Details- Type
- \Zend_Session_NameSpace


bool $_session = false
false
Details- Type
- bool


string $_sessionName = 'PHPSESSID'
Set the default session.name if php_
'PHPSESSID'
Details- Type
- string
Methods


_buildDispatchTable() : void
(Re)Build the dispatch table
The dispatch table consists of a an array of method name => Zend_Server_Reflection_Function_Abstract pairs


_castParameters(\Reflection $reflectionMethod, array $params) : array
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
Name | Type | Description |
---|---|---|
$reflectionMethod | \Reflection | |
$params | array |
Type | Description |
---|---|
array |


_checkAcl(string | object $object, string $function) : \unknown_type
Check if the ACL allows accessing the function or method
Name | Type | Description |
---|---|---|
$object | string | object | Object or class being accessed |
$function | string | Function or method being accessed |
Type | Description |
---|---|
\unknown_type |


_dispatch(string $method, $params = null, $source = null) : mixed
Loads a remote class or method and executes the function and returns the result
Name | Type | Description |
---|---|---|
$method | string | Is the method to execute |
$params | ||
$source |
Type | Description |
---|---|
mixed | $response the result of executing the method |
Exception | Description |
---|---|
\Zend_Amf_Server_Exception |


_errorMessage(int $objectEncoding, string $message, string $description, mixed $detail, int $code, int $line) : \Zend_Amf_Value_Messaging_ErrorMessage | array
Create appropriate error message
Name | Type | Description |
---|---|---|
$objectEncoding | int | 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 | int | Error code |
$line | int | Error line |
Type | Description |
---|---|
\Zend_Amf_Value_Messaging_ErrorMessage | array |


_handle(\Zend_Amf_Request $request) : \Zend_Amf_Response
Takes the deserialized AMF request and performs any operations.
Name | Type | Description |
---|---|---|
$request | \Zend_Amf_Request |
Type | Description |
---|---|
\Zend_Amf_Response |
Exception | Description |
---|---|
\Zend_Amf_server_Exception | \Exception |
- Todo
- should implement and SPL observer pattern for custom AMF headers
- Todo
- DescribeService support


_handleAuth(string $userid, string $password) : boolean
Handle AMF authentication
Name | Type | Description |
---|---|---|
$userid | string | |
$password | string |
Type | Description |
---|---|
boolean |


_loadCommandMessage(\Zend_Amf_Value_Messaging_CommandMessage $message) : \Zend_Amf_Value_Messaging_AcknowledgeMessage
Handles each of the 11 different command message types.
A command message is a flex.messaging.messages.CommandMessage
Name | Type | Description |
---|---|---|
$message | \Zend_Amf_Value_Messaging_CommandMessage |
Type | Description |
---|---|
\Zend_Amf_Value_Messaging_AcknowledgeMessage |
- See
- \global\Zend_Amf_Value_Messaging_CommandMessage


addDirectory(string $dir) : void
Creates an array of directories in which services can reside.
TODO: add support for prefixes?
Name | Type | Description |
---|---|---|
$dir | string |


addFunction(string | array $function, string $namespace = '') : \Zend_Amf_Server
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.
Name | Type | Description |
---|---|---|
$function | string | array | Valid callback |
$namespace | string | Optional namespace prefix |
Type | Description |
---|---|
\Zend_Amf_Server |
Exception | Description |
---|---|
\Zend_Amf_Server_Exception |


fault(string | \Exception $fault = null, $code = 404) : void
Raise a server fault
Unimplemented
Name | Type | Description |
---|---|---|
$fault | string | \Exception | |
$code |


getAuth() : \Zend_Amf_Auth_Abstract
Get authentication adapter
Type | Description |
---|---|
\Zend_Amf_Auth_Abstract |


getDirectory() : array
Returns an array of directories that can hold services.
Type | Description |
---|---|
array |


getFunctions() : array
Returns a list of registered methods
Returns an array of dispatchables (Zend_Server_Reflection_Function, _Method, and _Class items).
Type | Description |
---|---|
array |


getLoader() : \Zend_Loader_PluginLoader
Get PluginLoader for the Server
Type | Description |
---|---|
\Zend_Loader_PluginLoader |


getRequest() : null | \Zend_Amf_Request
Return currently registered request object
Type | Description |
---|---|
null | \Zend_Amf_Request |


getResponse() : \Zend_Amf_Server_Response
get a reference to the Zend_Amf_response instance
Type | Description |
---|---|
\Zend_Amf_Server_Response |


handle(null | \Zend_Amf_Request $request = null) : \Zend_Amf_Response
Handle an AMF call from the gateway.
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
Name | Type | Description |
---|---|---|
$request | null | \Zend_Amf_Request | Optional |
Type | Description |
---|---|
\Zend_Amf_Response |


listMethods() : array
List all available methods
Returns an array of method names.
Type | Description |
---|---|
array |


loadFunctions(array $definition) : void
Load server definition
Unimplemented
Name | Type | Description |
---|---|---|
$definition | array |


setAcl(\Zend_Acl $acl) : \Zend_Amf_Server
Set ACL adapter
Name | Type | Description |
---|---|---|
$acl | \Zend_Acl |
Type | Description |
---|---|
\Zend_Amf_Server |


setAuth(\Zend_Amf_Auth_Abstract $auth) : \Zend_Amf_Server
Set authentication adapter
If the authentication adapter implements a "getAcl()" method, populate the ACL of this instance with it (if none exists already).
Name | Type | Description |
---|---|---|
$auth | \Zend_Amf_Auth_Abstract |
Type | Description |
---|---|
\Zend_Amf_Server |


setClass(string | object $class, string $namespace = '', $argv = null) : \Zend_Amf_Server
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.
Name | Type | Description |
---|---|---|
$class | string | object | |
$namespace | string | Optional |
$argv |
Type | Description |
---|---|
\Zend_Amf_Server |
Exception | Description |
---|---|
\Zend_Amf_Server_Exception | on invalid input |


setClassMap(string $asClass, string $phpClass) : \Zend_Amf_Server
Map ActionScript classes to PHP classes
Name | Type | Description |
---|---|---|
$asClass | string | |
$phpClass | string |
Type | Description |
---|---|
\Zend_Amf_Server |


setPersistence(mixed $mode) : void
Set server persistence
Unimplemented
Name | Type | Description |
---|---|---|
$mode | mixed |


setProduction(bool $flag) : \Zend_Amf_Server
Set production flag
Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_Amf_Server |


setRequest(string | \Zend_Amf_Request $request) : \Zend_Amf_Server
Set request object
Name | Type | Description |
---|---|---|
$request | string | \Zend_Amf_Request |
Type | Description |
---|---|
\Zend_Amf_Server |


setResponse(string | \Zend_Amf_Server_Response $response) : \Zend_Amf_Server
Public access method to private Zend_Amf_Server_Response reference
Name | Type | Description |
---|---|---|
$response | string | \Zend_Amf_Server_Response |
Type | Description |
---|---|
\Zend_Amf_Server |


setSession(\namespace $namespace = 'Zend_Amf') : \Zend_Amf_Server
Name | Type | Description |
---|---|---|
$namespace | \namespace | of all incoming sessions defaults to Zend_Amf |
Type | Description |
---|---|
\Zend_Amf_Server |