CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.
This commit is contained in:
parent
514777e8d2
commit
b11cbd8159
4546 changed files with 138 additions and 51 deletions
205
airtime_mvc/library/Zend/Server/Method/Callback.php
Normal file
205
airtime_mvc/library/Zend/Server/Method/Callback.php
Normal file
|
@ -0,0 +1,205 @@
|
|||
<?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 license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Server
|
||||
* @subpackage Method
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Callback.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method callback metadata
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Server
|
||||
* @subpackage Method
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Server_Method_Callback
|
||||
{
|
||||
/**
|
||||
* @var string Class name for class method callback
|
||||
*/
|
||||
protected $_class;
|
||||
|
||||
/**
|
||||
* @var string Function name for function callback
|
||||
*/
|
||||
protected $_function;
|
||||
|
||||
/**
|
||||
* @var string Method name for class method callback
|
||||
*/
|
||||
protected $_method;
|
||||
|
||||
/**
|
||||
* @var string Callback type
|
||||
*/
|
||||
protected $_type;
|
||||
|
||||
/**
|
||||
* @var array Valid callback types
|
||||
*/
|
||||
protected $_types = array('function', 'static', 'instance');
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param null|array $options
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if ((null !== $options) && is_array($options)) {
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object state from array of options
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Server_Method_Callback
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
$method = 'set' . ucfirst($key);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set callback class
|
||||
*
|
||||
* @param string $class
|
||||
* @return Zend_Server_Method_Callback
|
||||
*/
|
||||
public function setClass($class)
|
||||
{
|
||||
if (is_object($class)) {
|
||||
$class = get_class($class);
|
||||
}
|
||||
$this->_class = $class;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get callback class
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->_class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set callback function
|
||||
*
|
||||
* @param string $function
|
||||
* @return Zend_Server_Method_Callback
|
||||
*/
|
||||
public function setFunction($function)
|
||||
{
|
||||
$this->_function = (string) $function;
|
||||
$this->setType('function');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get callback function
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getFunction()
|
||||
{
|
||||
return $this->_function;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set callback class method
|
||||
*
|
||||
* @param string $method
|
||||
* @return Zend_Server_Method_Callback
|
||||
*/
|
||||
public function setMethod($method)
|
||||
{
|
||||
$this->_method = $method;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get callback class method
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->_method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set callback type
|
||||
*
|
||||
* @param string $type
|
||||
* @return Zend_Server_Method_Callback
|
||||
* @throws Zend_Server_Exception
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
if (!in_array($type, $this->_types)) {
|
||||
require_once 'Zend/Server/Exception.php';
|
||||
throw new Zend_Server_Exception('Invalid method callback type passed to ' . __CLASS__ . '::' . __METHOD__);
|
||||
}
|
||||
$this->_type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get callback type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast callback to array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$type = $this->getType();
|
||||
$array = array(
|
||||
'type' => $type,
|
||||
);
|
||||
if ('function' == $type) {
|
||||
$array['function'] = $this->getFunction();
|
||||
} else {
|
||||
$array['class'] = $this->getClass();
|
||||
$array['method'] = $this->getMethod();
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
293
airtime_mvc/library/Zend/Server/Method/Definition.php
Normal file
293
airtime_mvc/library/Zend/Server/Method/Definition.php
Normal file
|
@ -0,0 +1,293 @@
|
|||
<?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 license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Server
|
||||
* @subpackage Method
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Definition.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method definition metadata
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Server
|
||||
* @subpackage Method
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Server_Method_Definition
|
||||
{
|
||||
/**
|
||||
* @var Zend_Server_Method_Callback
|
||||
*/
|
||||
protected $_callback;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_invokeArguments = array();
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_methodHelp = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* @var null|object
|
||||
*/
|
||||
protected $_object;
|
||||
|
||||
/**
|
||||
* @var array Array of Zend_Server_Method_Prototype objects
|
||||
*/
|
||||
protected $_prototypes = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param null|array $options
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if ((null !== $options) && is_array($options)) {
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object state from options
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
$method = 'set' . ucfirst($key);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set method name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->_name = (string) $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get method name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set method callback
|
||||
*
|
||||
* @param array|Zend_Server_Method_Callback $callback
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function setCallback($callback)
|
||||
{
|
||||
if (is_array($callback)) {
|
||||
require_once 'Zend/Server/Method/Callback.php';
|
||||
$callback = new Zend_Server_Method_Callback($callback);
|
||||
} elseif (!$callback instanceof Zend_Server_Method_Callback) {
|
||||
require_once 'Zend/Server/Exception.php';
|
||||
throw new Zend_Server_Exception('Invalid method callback provided');
|
||||
}
|
||||
$this->_callback = $callback;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get method callback
|
||||
*
|
||||
* @return Zend_Server_Method_Callback
|
||||
*/
|
||||
public function getCallback()
|
||||
{
|
||||
return $this->_callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add prototype to method definition
|
||||
*
|
||||
* @param array|Zend_Server_Method_Prototype $prototype
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function addPrototype($prototype)
|
||||
{
|
||||
if (is_array($prototype)) {
|
||||
require_once 'Zend/Server/Method/Prototype.php';
|
||||
$prototype = new Zend_Server_Method_Prototype($prototype);
|
||||
} elseif (!$prototype instanceof Zend_Server_Method_Prototype) {
|
||||
require_once 'Zend/Server/Exception.php';
|
||||
throw new Zend_Server_Exception('Invalid method prototype provided');
|
||||
}
|
||||
$this->_prototypes[] = $prototype;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple prototypes at once
|
||||
*
|
||||
* @param array $prototypes Array of Zend_Server_Method_Prototype objects or arrays
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function addPrototypes(array $prototypes)
|
||||
{
|
||||
foreach ($prototypes as $prototype) {
|
||||
$this->addPrototype($prototype);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all prototypes at once (overwrites)
|
||||
*
|
||||
* @param array $prototypes Array of Zend_Server_Method_Prototype objects or arrays
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function setPrototypes(array $prototypes)
|
||||
{
|
||||
$this->_prototypes = array();
|
||||
$this->addPrototypes($prototypes);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all prototypes
|
||||
*
|
||||
* @return array $prototypes Array of Zend_Server_Method_Prototype objects or arrays
|
||||
*/
|
||||
public function getPrototypes()
|
||||
{
|
||||
return $this->_prototypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set method help
|
||||
*
|
||||
* @param string $methodHelp
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function setMethodHelp($methodHelp)
|
||||
{
|
||||
$this->_methodHelp = (string) $methodHelp;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get method help
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethodHelp()
|
||||
{
|
||||
return $this->_methodHelp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object to use with method calls
|
||||
*
|
||||
* @param object $object
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function setObject($object)
|
||||
{
|
||||
if (!is_object($object) && (null !== $object)) {
|
||||
require_once 'Zend/Server/Exception.php';
|
||||
throw new Zend_Server_Exception('Invalid object passed to ' . __CLASS__ . '::' . __METHOD__);
|
||||
}
|
||||
$this->_object = $object;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object to use with method calls
|
||||
*
|
||||
* @return null|object
|
||||
*/
|
||||
public function getObject()
|
||||
{
|
||||
return $this->_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set invoke arguments
|
||||
*
|
||||
* @param array $invokeArguments
|
||||
* @return Zend_Server_Method_Definition
|
||||
*/
|
||||
public function setInvokeArguments(array $invokeArguments)
|
||||
{
|
||||
$this->_invokeArguments = $invokeArguments;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve invoke arguments
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getInvokeArguments()
|
||||
{
|
||||
return $this->_invokeArguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize to array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$prototypes = $this->getPrototypes();
|
||||
$signatures = array();
|
||||
foreach ($prototypes as $prototype) {
|
||||
$signatures[] = $prototype->toArray();
|
||||
}
|
||||
|
||||
return array(
|
||||
'name' => $this->getName(),
|
||||
'callback' => $this->getCallback()->toArray(),
|
||||
'prototypes' => $signatures,
|
||||
'methodHelp' => $this->getMethodHelp(),
|
||||
'invokeArguments' => $this->getInvokeArguments(),
|
||||
'object' => $this->getObject(),
|
||||
);
|
||||
}
|
||||
}
|
214
airtime_mvc/library/Zend/Server/Method/Parameter.php
Normal file
214
airtime_mvc/library/Zend/Server/Method/Parameter.php
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?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 license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Server
|
||||
* @subpackage Method
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Parameter.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method parameter metadata
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Server
|
||||
* @subpackage Method
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Server_Method_Parameter
|
||||
{
|
||||
/**
|
||||
* @var mixed Default parameter value
|
||||
*/
|
||||
protected $_defaultValue;
|
||||
|
||||
/**
|
||||
* @var string Parameter description
|
||||
*/
|
||||
protected $_description = '';
|
||||
|
||||
/**
|
||||
* @var string Parameter variable name
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* @var bool Is parameter optional?
|
||||
*/
|
||||
protected $_optional = false;
|
||||
|
||||
/**
|
||||
* @var string Parameter type
|
||||
*/
|
||||
protected $_type = 'mixed';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param null|array $options
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object state from array of options
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Server_Method_Parameter
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
$method = 'set' . ucfirst($key);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default value
|
||||
*
|
||||
* @param mixed $defaultValue
|
||||
* @return Zend_Server_Method_Parameter
|
||||
*/
|
||||
public function setDefaultValue($defaultValue)
|
||||
{
|
||||
$this->_defaultValue = $defaultValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve default value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
return $this->_defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
* @param string $description
|
||||
* @return Zend_Server_Method_Parameter
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->_description = (string) $description;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Zend_Server_Method_Parameter
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->_name = (string) $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set optional flag
|
||||
*
|
||||
* @param bool $flag
|
||||
* @return Zend_Server_Method_Parameter
|
||||
*/
|
||||
public function setOptional($flag)
|
||||
{
|
||||
$this->_optional = (bool) $flag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the parameter optional?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOptional()
|
||||
{
|
||||
return $this->_optional;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parameter type
|
||||
*
|
||||
* @param string $type
|
||||
* @return Zend_Server_Method_Parameter
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->_type = (string) $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve parameter type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast to array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array(
|
||||
'type' => $this->getType(),
|
||||
'name' => $this->getName(),
|
||||
'optional' => $this->isOptional(),
|
||||
'defaultValue' => $this->getDefaultValue(),
|
||||
'description' => $this->getDescription(),
|
||||
);
|
||||
}
|
||||
}
|
208
airtime_mvc/library/Zend/Server/Method/Prototype.php
Normal file
208
airtime_mvc/library/Zend/Server/Method/Prototype.php
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?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 license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Server
|
||||
* @subpackage Method
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Prototype.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method prototype metadata
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Server
|
||||
* @subpackage Method
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Server_Method_Prototype
|
||||
{
|
||||
/**
|
||||
* @var string Return type
|
||||
*/
|
||||
protected $_returnType = 'void';
|
||||
|
||||
/**
|
||||
* @var array Map parameter names to parameter index
|
||||
*/
|
||||
protected $_parameterNameMap = array();
|
||||
|
||||
/**
|
||||
* @var array Method parameters
|
||||
*/
|
||||
protected $_parameters = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param null|array $options
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if ((null !== $options) && is_array($options)) {
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set return value
|
||||
*
|
||||
* @param string $returnType
|
||||
* @return Zend_Server_Method_Prototype
|
||||
*/
|
||||
public function setReturnType($returnType)
|
||||
{
|
||||
$this->_returnType = $returnType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve return type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnType()
|
||||
{
|
||||
return $this->_returnType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a parameter
|
||||
*
|
||||
* @param string $parameter
|
||||
* @return Zend_Server_Method_Prototype
|
||||
*/
|
||||
public function addParameter($parameter)
|
||||
{
|
||||
if ($parameter instanceof Zend_Server_Method_Parameter) {
|
||||
$this->_parameters[] = $parameter;
|
||||
if (null !== ($name = $parameter->getName())) {
|
||||
$this->_parameterNameMap[$name] = count($this->_parameters) - 1;
|
||||
}
|
||||
} else {
|
||||
require_once 'Zend/Server/Method/Parameter.php';
|
||||
$parameter = new Zend_Server_Method_Parameter(array(
|
||||
'type' => (string) $parameter,
|
||||
));
|
||||
$this->_parameters[] = $parameter;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add parameters
|
||||
*
|
||||
* @param array $parameter
|
||||
* @return Zend_Server_Method_Prototype
|
||||
*/
|
||||
public function addParameters(array $parameters)
|
||||
{
|
||||
foreach ($parameters as $parameter) {
|
||||
$this->addParameter($parameter);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parameters
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return Zend_Server_Method_Prototype
|
||||
*/
|
||||
public function setParameters(array $parameters)
|
||||
{
|
||||
$this->_parameters = array();
|
||||
$this->_parameterNameMap = array();
|
||||
$this->addParameters($parameters);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve parameters as list of types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
$types = array();
|
||||
foreach ($this->_parameters as $parameter) {
|
||||
$types[] = $parameter->getType();
|
||||
}
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parameter objects
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameterObjects()
|
||||
{
|
||||
return $this->_parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single parameter by name or index
|
||||
*
|
||||
* @param string|int $index
|
||||
* @return null|Zend_Server_Method_Parameter
|
||||
*/
|
||||
public function getParameter($index)
|
||||
{
|
||||
if (!is_string($index) && !is_numeric($index)) {
|
||||
return null;
|
||||
}
|
||||
if (array_key_exists($index, $this->_parameterNameMap)) {
|
||||
$index = $this->_parameterNameMap[$index];
|
||||
}
|
||||
if (array_key_exists($index, $this->_parameters)) {
|
||||
return $this->_parameters[$index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object state from array
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Server_Method_Prototype
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
$method = 'set' . ucfirst($key);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize to array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array(
|
||||
'returnType' => $this->getReturnType(),
|
||||
'parameters' => $this->getParameters(),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue