/libraries/Zend/Amf/Value/MessageBody.php

https://github.com/kiranatama/sagalaya · PHP · 183 lines · 55 code · 12 blank · 116 comment · 3 complexity · f1ea18f3ffaa37fb4006891679e9cbd3 MD5 · raw file

  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Amf
  17. * @subpackage Value
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. namespace Zend\Amf\Value;
  22. /**
  23. * An AMF Message contains information about the actual individual
  24. * transaction that is to be performed. It specifies the remote
  25. * operation that is to be performed; a local (client) operation
  26. * to be invoked upon success; and, the data to be used in the
  27. * operation.
  28. * <p/>
  29. * This Message structure defines how a local client would
  30. * invoke a method/operation on a remote server. Additionally,
  31. * the response from the Server is structured identically.
  32. *
  33. * @package Zend_Amf
  34. * @subpackage Value
  35. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class MessageBody
  39. {
  40. /**
  41. * A string describing which operation, function, or method
  42. * is to be remotley invoked.
  43. * @var string
  44. */
  45. protected $_targetUri = "";
  46. /**
  47. * Universal Resource Identifier that uniquely targets the originator's
  48. * Object that should receive the server's response. The server will
  49. * use this path specification to target the "OnResult()" or "onStatus()"
  50. * handlers within the client. For Flash, it specifies an ActionScript
  51. * Object path only. The NetResponse object pointed to by the Response Uri
  52. * contains the connection state information. Passing/specifying this
  53. * provides a convenient mechanism for the client/server to share access
  54. * to an object that is managing the state of the shared connection.
  55. *
  56. * Since the server will use this field in the event of an error,
  57. * this field is required even if a successful server request would
  58. * not be expected to return a value to the client.
  59. *
  60. * @var string
  61. */
  62. protected $_responseUri = "";
  63. /**
  64. * Contains the actual data associated with the operation. It contains
  65. * the client's parameter data that is passed to the server's operation/method.
  66. * When serializing a root level data type or a parameter list array, no
  67. * name field is included. That is, the data is anonomously represented
  68. * as "Type Marker"/"Value" pairs. When serializing member data, the data is
  69. * represented as a series of "Name"/"Type"/"Value" combinations.
  70. *
  71. * For server generated responses, it may contain any ActionScript
  72. * data/objects that the server was expected to provide.
  73. *
  74. * @var string
  75. */
  76. protected $_data;
  77. /**
  78. * Constructor
  79. *
  80. * @param string $targetUri
  81. * @param string $responseUri
  82. * @param string $data
  83. * @return void
  84. */
  85. public function __construct($targetUri, $responseUri, $data)
  86. {
  87. $this->setTargetUri($targetUri);
  88. $this->setResponseUri($responseUri);
  89. $this->setData($data);
  90. }
  91. /**
  92. * Retrieve target Uri
  93. *
  94. * @return string
  95. */
  96. public function getTargetUri()
  97. {
  98. return $this->_targetUri;
  99. }
  100. /**
  101. * Set target Uri
  102. *
  103. * @param string $targetUri
  104. * @return \Zend\Amf\Value\MessageBody
  105. */
  106. public function setTargetUri($targetUri)
  107. {
  108. if (null === $targetUri) {
  109. $targetUri = '';
  110. }
  111. $this->_targetUri = (string) $targetUri;
  112. return $this;
  113. }
  114. /**
  115. * Get target Uri
  116. *
  117. * @return string
  118. */
  119. public function getResponseUri()
  120. {
  121. return $this->_responseUri;
  122. }
  123. /**
  124. * Set response Uri
  125. *
  126. * @param string $responseUri
  127. * @return \Zend\Amf\Value\MessageBody
  128. */
  129. public function setResponseUri($responseUri)
  130. {
  131. if (null === $responseUri) {
  132. $responseUri = '';
  133. }
  134. $this->_responseUri = $responseUri;
  135. return $this;
  136. }
  137. /**
  138. * Retrieve response data
  139. *
  140. * @return string
  141. */
  142. public function getData()
  143. {
  144. return $this->_data;
  145. }
  146. /**
  147. * Set response data
  148. *
  149. * @param mixed $data
  150. * @return \Zend\Amf\Value\MessageBody
  151. */
  152. public function setData($data)
  153. {
  154. $this->_data = $data;
  155. return $this;
  156. }
  157. /**
  158. * Set reply method
  159. *
  160. * @param string $methodName
  161. * @return \Zend\Amf\Value\MessageBody
  162. */
  163. public function setReplyMethod($methodName)
  164. {
  165. if (!preg_match('#^[/?]#', $methodName)) {
  166. $this->_targetUri = rtrim($this->_targetUri, '/') . '/';
  167. }
  168. $this->_targetUri = $this->_targetUri . $methodName;
  169. return $this;
  170. }
  171. }