File indexing completed on 2024-12-22 05:36:27
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Amf 0017 * @subpackage Value 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * An AMF Message contains information about the actual individual 0025 * transaction that is to be performed. It specifies the remote 0026 * operation that is to be performed; a local (client) operation 0027 * to be invoked upon success; and, the data to be used in the 0028 * operation. 0029 * <p/> 0030 * This Message structure defines how a local client would 0031 * invoke a method/operation on a remote server. Additionally, 0032 * the response from the Server is structured identically. 0033 * 0034 * @package Zend_Amf 0035 * @subpackage Value 0036 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0037 * @license http://framework.zend.com/license/new-bsd New BSD License 0038 */ 0039 class Zend_Amf_Value_MessageBody 0040 { 0041 /** 0042 * A string describing which operation, function, or method 0043 * is to be remotley invoked. 0044 * @var string 0045 */ 0046 protected $_targetUri = ""; 0047 0048 /** 0049 * Universal Resource Identifier that uniquely targets the originator's 0050 * Object that should receive the server's response. The server will 0051 * use this path specification to target the "OnResult()" or "onStatus()" 0052 * handlers within the client. For Flash, it specifies an ActionScript 0053 * Object path only. The NetResponse object pointed to by the Response Uri 0054 * contains the connection state information. Passing/specifying this 0055 * provides a convenient mechanism for the client/server to share access 0056 * to an object that is managing the state of the shared connection. 0057 * 0058 * Since the server will use this field in the event of an error, 0059 * this field is required even if a successful server request would 0060 * not be expected to return a value to the client. 0061 * 0062 * @var string 0063 */ 0064 protected $_responseUri = ""; 0065 0066 /** 0067 * Contains the actual data associated with the operation. It contains 0068 * the client's parameter data that is passed to the server's operation/method. 0069 * When serializing a root level data type or a parameter list array, no 0070 * name field is included. That is, the data is anonomously represented 0071 * as "Type Marker"/"Value" pairs. When serializing member data, the data is 0072 * represented as a series of "Name"/"Type"/"Value" combinations. 0073 * 0074 * For server generated responses, it may contain any ActionScript 0075 * data/objects that the server was expected to provide. 0076 * 0077 * @var string 0078 */ 0079 protected $_data; 0080 0081 /** 0082 * Constructor 0083 * 0084 * @param string $targetUri 0085 * @param string $responseUri 0086 * @param string $data 0087 * @return void 0088 */ 0089 public function __construct($targetUri, $responseUri, $data) 0090 { 0091 $this->setTargetUri($targetUri); 0092 $this->setResponseUri($responseUri); 0093 $this->setData($data); 0094 } 0095 0096 /** 0097 * Retrieve target Uri 0098 * 0099 * @return string 0100 */ 0101 public function getTargetUri() 0102 { 0103 return $this->_targetUri; 0104 } 0105 0106 /** 0107 * Set target Uri 0108 * 0109 * @param string $targetUri 0110 * @return Zend_Amf_Value_MessageBody 0111 */ 0112 public function setTargetUri($targetUri) 0113 { 0114 if (null === $targetUri) { 0115 $targetUri = ''; 0116 } 0117 $this->_targetUri = (string) $targetUri; 0118 return $this; 0119 } 0120 0121 /** 0122 * Get target Uri 0123 * 0124 * @return string 0125 */ 0126 public function getResponseUri() 0127 { 0128 return $this->_responseUri; 0129 } 0130 0131 /** 0132 * Set response Uri 0133 * 0134 * @param string $responseUri 0135 * @return Zend_Amf_Value_MessageBody 0136 */ 0137 public function setResponseUri($responseUri) 0138 { 0139 if (null === $responseUri) { 0140 $responseUri = ''; 0141 } 0142 $this->_responseUri = $responseUri; 0143 return $this; 0144 } 0145 0146 /** 0147 * Retrieve response data 0148 * 0149 * @return string 0150 */ 0151 public function getData() 0152 { 0153 return $this->_data; 0154 } 0155 0156 /** 0157 * Set response data 0158 * 0159 * @param mixed $data 0160 * @return Zend_Amf_Value_MessageBody 0161 */ 0162 public function setData($data) 0163 { 0164 $this->_data = $data; 0165 return $this; 0166 } 0167 0168 /** 0169 * Set reply method 0170 * 0171 * @param string $methodName 0172 * @return Zend_Amf_Value_MessageBody 0173 */ 0174 public function setReplyMethod($methodName) 0175 { 0176 if (!preg_match('#^[/?]#', $methodName)) { 0177 $this->_targetUri = rtrim($this->_targetUri, '/') . '/'; 0178 } 0179 $this->_targetUri = $this->_targetUri . $methodName; 0180 return $this; 0181 } 0182 }