Amf/Server.php

Show: PublicProtectedPrivateinherited
Table of Contents
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 license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Amf  
Version
$Id$  

\Zend_Amf_Server

Package: Zend_Amf\Server
An AMF gateway server implementation to allow the connection of the Adobe Flash Player to Zend Framework
Implements
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Todo
Make the reflection methods cache and autoload.  

Properties

>VPropertyprotected\Zend_Acl $_acl
ACL handler object
Details
Type
\Zend_Acl
>VPropertyprotected\Zend_Amf_Auth_Abstract $_auth
Authentication handler object
>VPropertyprotectedarray $_classAllowed = array()
Array of classes that can be called without being explicitly loaded
Keys are class names.
Default valuearray()Details
Type
array
>VPropertyprotected\Zend_Loader_PluginLoader $_loader
Loader for classes in added directories
>VPropertyprotectedarray $_methods = array()
Array of dispatchables
Default valuearray()Details
Type
array
>VPropertyprotectedbool $_production = true

Production flag; whether or not to return exception messages

Default valuetrueDetails
Type
bool
>VPropertyprotectednull|\Zend_Amf_Request $_request = null
Request processed
Default valuenullDetails
Type
null | \Zend_Amf_Request
>VPropertyprotectednull|\Zend_Amf_Response $_response
Class to use for responses
Details
Type
null | \Zend_Amf_Response
>VPropertyprotected\Zend_Session_NameSpace $_sesionNamespace = 'zend_amf'
Namespace allows all AMF calls to not clobber other PHP session variables
Default value'zend_amf'Details
Type
\Zend_Session_NameSpace
>VPropertyprotectedbool $_session = false

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

Default valuefalseDetails
Type
bool
>VPropertyprotectedstring $_sessionName = 'PHPSESSID'
Set the default session.name if php_
Default value'PHPSESSID'Details
Type
string
>VPropertyprotectedarray $_table = array()
Dispatch table of name => method pairs
Default valuearray()Details
Type
array

Methods

methodpublic__construct() : void

The server constructor

methodprotected_buildDispatchTable() : void

(Re)Build the dispatch table

The dispatch table consists of a an array of method name => Zend_Server_Reflection_Function_Abstract pairs
methodprotected_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
Parameters
NameTypeDescription
$reflectionMethod\Reflection
$paramsarray
Returns
TypeDescription
array
methodprotected_checkAcl(string | object $object, string $function) : \unknown_type

Check if the ACL allows accessing the function or method

Parameters
NameTypeDescription
$objectstring | object

Object or class being accessed

$functionstring

Function or method being accessed

Returns
TypeDescription
\unknown_type
methodprotected_dispatch(string $method,  $params = null,  $source = null) : mixed

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

Parameters
NameTypeDescription
$methodstring

Is the method to execute

$params
$source
Returns
TypeDescription
mixed$response the result of executing the method
Throws
ExceptionDescription
\Zend_Amf_Server_Exception
methodprotected_errorMessage(int $objectEncoding, string $message, string $description, mixed $detail, int $code, int $line) : \Zend_Amf_Value_Messaging_ErrorMessage | array

Create appropriate error message

Parameters
NameTypeDescription
$objectEncodingint

Current AMF encoding

$messagestring

Message that was being processed when error happened

$descriptionstring

Error description

$detailmixed

Detailed data about the error

$codeint

Error code

$lineint

Error line

Returns
TypeDescription
\Zend_Amf_Value_Messaging_ErrorMessage | array
methodprotected_handle(\Zend_Amf_Request $request) : \Zend_Amf_Response

Takes the deserialized AMF request and performs any operations.

Parameters
NameTypeDescription
$request\Zend_Amf_Request
Returns
TypeDescription
\Zend_Amf_Response
Throws
ExceptionDescription
\Zend_Amf_server_Exception | \Exception
Details
Todo
should implement and SPL observer pattern for custom AMF headers  
Todo
DescribeService support  
methodprotected_handleAuth(string $userid, string $password) : boolean

Handle AMF authentication

Parameters
NameTypeDescription
$useridstring
$passwordstring
Returns
TypeDescription
boolean
methodprotected_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
Parameters
NameTypeDescription
$message\Zend_Amf_Value_Messaging_CommandMessage
Returns
TypeDescription
\Zend_Amf_Value_Messaging_AcknowledgeMessage
Details
See
 
methodpublicaddDirectory(string $dir) : void

Creates an array of directories in which services can reside.

TODO: add support for prefixes?
Parameters
NameTypeDescription
$dirstring
methodpublicaddFunction(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.
Parameters
NameTypeDescription
$functionstring | array

Valid callback

$namespacestring

Optional namespace prefix

Returns
TypeDescription
\Zend_Amf_Server
Throws
ExceptionDescription
\Zend_Amf_Server_Exception
methodpublicfault(string | \Exception $fault = null,  $code = 404) : void

Raise a server fault

Unimplemented
Parameters
NameTypeDescription
$faultstring | \Exception
$code
methodpublicgetAcl() : \Zend_Acl

Get ACL adapter

Returns
TypeDescription
\Zend_Acl
methodpublicgetAuth() : \Zend_Amf_Auth_Abstract

Get authentication adapter

Returns
TypeDescription
\Zend_Amf_Auth_Abstract
methodpublicgetDirectory() : array

Returns an array of directories that can hold services.

Returns
TypeDescription
array
methodpublicgetFunctions() : array

Returns a list of registered methods

Returns an array of dispatchables (Zend_Server_Reflection_Function, _Method, and _Class items).
Returns
TypeDescription
array
methodprotectedgetLoader() : \Zend_Loader_PluginLoader

Get PluginLoader for the Server

Returns
TypeDescription
\Zend_Loader_PluginLoader
methodpublicgetRequest() : null | \Zend_Amf_Request

Return currently registered request object

Returns
TypeDescription
null | \Zend_Amf_Request
methodpublicgetResponse() : \Zend_Amf_Server_Response

get a reference to the Zend_Amf_response instance

Returns
TypeDescription
\Zend_Amf_Server_Response
methodpublichandle(null | \Zend_Amf_Request $request = null) : \Zend_Amf_Response

Handle an AMF call from the gateway.

Parameters
NameTypeDescription
$requestnull | \Zend_Amf_Request

Optional

Returns
TypeDescription
\Zend_Amf_Response
methodpublicisProduction() : bool

Whether or not the server is in production

Returns
TypeDescription
bool
methodpublicisSession() : bool

Whether of not the server is using sessions

Returns
TypeDescription
bool
methodpubliclistMethods() : array

List all available methods

Returns an array of method names.
Returns
TypeDescription
array
methodpublicloadFunctions(array $definition) : void

Load server definition

Unimplemented
Parameters
NameTypeDescription
$definitionarray
methodpublicsetAcl(\Zend_Acl $acl) : \Zend_Amf_Server

Set ACL adapter

Parameters
NameTypeDescription
$acl\Zend_Acl
Returns
TypeDescription
\Zend_Amf_Server
methodpublicsetAuth(\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).
Parameters
NameTypeDescription
$auth\Zend_Amf_Auth_Abstract
Returns
TypeDescription
\Zend_Amf_Server
methodpublicsetClass(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.
Parameters
NameTypeDescription
$classstring | object
$namespacestring

Optional

$argv
Returns
TypeDescription
\Zend_Amf_Server
Throws
ExceptionDescription
\Zend_Amf_Server_Exceptionon invalid input
methodpublicsetClassMap(string $asClass, string $phpClass) : \Zend_Amf_Server

Map ActionScript classes to PHP classes

Parameters
NameTypeDescription
$asClassstring
$phpClassstring
Returns
TypeDescription
\Zend_Amf_Server
methodpublicsetPersistence(mixed $mode) : void

Set server persistence

Unimplemented
Parameters
NameTypeDescription
$modemixed
methodpublicsetProduction(bool $flag) : \Zend_Amf_Server

Set production flag

Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Amf_Server
methodpublicsetRequest(string | \Zend_Amf_Request $request) : \Zend_Amf_Server

Set request object

Parameters
NameTypeDescription
$requeststring | \Zend_Amf_Request
Returns
TypeDescription
\Zend_Amf_Server
methodpublicsetResponse(string | \Zend_Amf_Server_Response $response) : \Zend_Amf_Server

Public access method to private Zend_Amf_Server_Response reference

Parameters
NameTypeDescription
$responsestring | \Zend_Amf_Server_Response
Returns
TypeDescription
\Zend_Amf_Server
methodpublicsetSession( $namespace = 'Zend_Amf') : \Zend_Amf_Server

Parameters
NameTypeDescription
$namespace
Returns
TypeDescription
\Zend_Amf_Server
Documentation was generated by phpDocumentor 2.2.0 .