Guest User

Untitled

a guest
Mar 8th, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.16 KB | None | 0 0
  1. Index: controller/AgaviController.class.php
  2. ===================================================================
  3. --- controller/AgaviController.class.php (revision 2101)
  4. +++ controller/AgaviController.class.php (working copy)
  5. @@ -70,6 +70,11 @@
  6. protected $outputTypes = array();
  7.  
  8. /**
  9. + * @var array Ref to the request data object from the request.
  10. + */
  11. + private $requestData = null;
  12. +
  13. + /**
  14. * Indicates whether or not a module has a specific action.
  15. *
  16. * @param string A module name.
  17. @@ -131,7 +136,7 @@
  18. // create a new execution container
  19. $ecfi = $this->context->getFactoryInfo('execution_container');
  20. $container = new $ecfi['class']();
  21. - $container->initialize($this->context, $ecfi['parameters']);
  22. + $container->initialize($this->context, $this->requestData, $ecfi['parameters']);
  23. $container->setModuleName($moduleName);
  24. $container->setActionName($actionName);
  25. if($arguments !== null) {
  26. @@ -479,6 +484,8 @@
  27. */
  28. public function startup()
  29. {
  30. + // grab a pointer to the request data
  31. + $this->requestData = $this->context->getRequest()->getRequestData();
  32. }
  33.  
  34. /**
  35. Index: controller/AgaviExecutionContainer.class.php
  36. ===================================================================
  37. --- controller/AgaviExecutionContainer.class.php (revision 2101)
  38. +++ controller/AgaviExecutionContainer.class.php (working copy)
  39. @@ -43,7 +43,7 @@
  40. /**
  41. * @var AgaviRequestDataHolder A request data holder with request info.
  42. */
  43. - protected $requestData = null;
  44. + private $requestData = null;
  45.  
  46. /**
  47. * @var AgaviRequestDataHolder A request data holder with arguments.
  48. @@ -143,11 +143,13 @@
  49. * @author David Zülke <dz@bitxtender.com>
  50. * @since 0.11.0
  51. */
  52. - public function initialize(AgaviContext $context, array $parameters = array())
  53. + public function initialize(AgaviContext $context, AgaviRequestDataHolder $rd, array $parameters = array())
  54. {
  55. $this->microtime = microtime(true);
  56.  
  57. $this->context = $context;
  58. +
  59. + $this->requestData = $rd;
  60.  
  61. $this->parameters = $parameters;
  62. }
  63. @@ -296,8 +298,6 @@
  64. // run the execution filter, without a proper chain
  65. $controller->getFilter('execution')->execute(new AgaviFilterChain(), $this);
  66. } else {
  67. - $this->requestData = clone $request->getRequestData();
  68. -
  69. if($this->arguments !== null) {
  70. $this->requestData->merge($this->arguments);
  71. }
  72. @@ -400,9 +400,11 @@
  73. * @author David Zülke <dz@bitxtender.com>
  74. * @since 0.11.0
  75. */
  76. - public function getRequestData()
  77. + public final function getRequestData()
  78. {
  79. - return $this->requestData;
  80. + if($this->actionInstance !== null) {
  81. + return $this->requestData;
  82. + }
  83. }
  84.  
  85. /**
  86. Index: request/AgaviXmlrpcepiphpRequest.class.php
  87. ===================================================================
  88. --- request/AgaviXmlrpcepiphpRequest.class.php (revision 2101)
  89. +++ request/AgaviXmlrpcepiphpRequest.class.php (working copy)
  90. @@ -54,20 +54,19 @@
  91. }
  92.  
  93. $rdhc = $this->getParameter('request_data_holder_class');
  94. - $this->requestData = new $rdhc(array(
  95. - constant("$rdhc::SOURCE_PARAMETERS") => array(),
  96. + $rd = new $rdhc(array(
  97. + constant("$rdhc::SOURCE_PARAMETERS") => (array)$decoded,
  98. ));
  99.  
  100. -
  101. - $this->requestData->setParameters((array)$decoded);
  102. -
  103. $split = explode(':', $this->invokedMethod);
  104. if(count($split) == 2) {
  105. - $this->requestData->setParameter($this->getParameter('module_accessor'), $split[0]);
  106. - $this->requestData->setParameter($this->getParameter('action_accessor'), $split[1]);
  107. + $rd->setParameter($this->getParameter('module_accessor'), $split[0]);
  108. + $rd->setParameter($this->getParameter('action_accessor'), $split[1]);
  109. } else {
  110. - $this->requestData->setParameter($this->getParameter('action_accessor'), $this->invokedMethod);
  111. + $rd->setParameter($this->getParameter('action_accessor'), $this->invokedMethod);
  112. }
  113. +
  114. + $this->setRequestData($rd);
  115. }
  116. }
  117.  
  118. Index: request/AgaviWebRequest.class.php
  119. ===================================================================
  120. --- request/AgaviWebRequest.class.php (revision 2101)
  121. +++ request/AgaviWebRequest.class.php (working copy)
  122. @@ -378,12 +378,12 @@
  123. }
  124.  
  125. $rdhc = $this->getParameter('request_data_holder_class');
  126. - $this->requestData = new $rdhc(array(
  127. + $this->setRequestData(new $rdhc(array(
  128. constant("$rdhc::SOURCE_PARAMETERS") => array_merge($_GET, $_POST),
  129. constant("$rdhc::SOURCE_COOKIES") => $_COOKIE,
  130. constant("$rdhc::SOURCE_FILES") => $_FILES,
  131. constant("$rdhc::SOURCE_HEADERS") => $headers,
  132. - ));
  133. + )));
  134. }
  135.  
  136. /**
  137. Index: request/AgaviRequest.class.php
  138. ===================================================================
  139. --- request/AgaviRequest.class.php (revision 2101)
  140. +++ request/AgaviRequest.class.php (working copy)
  141. @@ -54,7 +54,7 @@
  142. /**
  143. * @var AgaviRequestDataHolder The request data holder instance.
  144. */
  145. - protected $requestData = null;
  146. + private $requestData = null;
  147.  
  148. /**
  149. * @var bool A boolean value indicating whether or not the request is
  150. @@ -173,21 +173,34 @@
  151. }
  152.  
  153. /**
  154. + * Set the data holder instance of this request.
  155. + *
  156. + * @param AgaviRequestDataHolder The request data holder.
  157. + *
  158. + * @author David Zülke <dz@bitxtender.com>
  159. + * @author Dominik del Bondio <ddb@bitxtender.com>
  160. + * @since 0.11.0
  161. + */
  162. + final protected function setRequestData(AgaviRequestDataHolder $rd)
  163. + {
  164. + if(!$this->locked) {
  165. + $this->requestData = $rd;
  166. + }
  167. + }
  168. +
  169. + /**
  170. * Get the data holder instance of this request.
  171. *
  172. * @return AgaviRequestDataHolder The request data holder.
  173. *
  174. + * @author David Zülke <dz@bitxtender.com>
  175. * @author Dominik del Bondio <ddb@bitxtender.com>
  176. * @since 0.11.0
  177. */
  178. - public function getRequestData()
  179. + final public function getRequestData()
  180. {
  181. if($this->locked) {
  182. - if($this->getParameter('request_lock_barf', true)) {
  183. - throw new AgaviException("Access to request data is locked during Action and View execution, please use the local request data holder passed to your Action's or View's execute*() method to access request data.\nYou may disable the throwing of this exception by setting the 'request_lock_barf' parameter to false. Sorry for the name of that one, 'throw_exception_when_trying_to_access_request_data_while_request_is_locked' is just a little too long.");
  184. - } else {
  185. - return new AgaviRequestDataHolder();
  186. - }
  187. + return new AgaviRequestDataHolder();
  188. }
  189. return $this->requestData;
  190. }
  191. Index: request/AgaviSoapRequest.class.php
  192. ===================================================================
  193. --- request/AgaviSoapRequest.class.php (revision 2101)
  194. +++ request/AgaviSoapRequest.class.php (working copy)
  195. @@ -62,10 +62,10 @@
  196. parent::initialize($context, $parameters);
  197.  
  198. $rdhc = $this->getParameter('request_data_holder_class');
  199. - $this->requestData = new $rdhc(array(
  200. + $this->setRequestData(new $rdhc(array(
  201. constant("$rdhc::SOURCE_PARAMETERS") => array(),
  202. constant("$rdhc::SOURCE_HEADERS") => array(),
  203. - ));
  204. + )));
  205.  
  206. $this->setMethod($this->getParameter('default_method', 'read'));
  207. }
Add Comment
Please, Sign In to add comment