Guest User

Untitled

a guest
Apr 13th, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.72 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. @@ -134,6 +139,7 @@
  18. $container->initialize($this->context, $ecfi['parameters']);
  19. $container->setModuleName($moduleName);
  20. $container->setActionName($actionName);
  21. + $container->setRequestData($this->requestData);
  22. if($arguments !== null) {
  23. $container->setArguments($arguments);
  24. }
  25. @@ -479,6 +485,8 @@
  26. */
  27. public function startup()
  28. {
  29. + // grab a pointer to the request data
  30. + $this->requestData = $this->context->getRequest()->getRequestData();
  31. }
  32.  
  33. /**
  34. Index: controller/AgaviExecutionContainer.class.php
  35. ===================================================================
  36. --- controller/AgaviExecutionContainer.class.php (revision 2101)
  37. +++ controller/AgaviExecutionContainer.class.php (working copy)
  38. @@ -43,7 +43,7 @@
  39. /**
  40. * @var AgaviRequestDataHolder A request data holder with request info.
  41. */
  42. - protected $requestData = null;
  43. + private $requestData = null;
  44.  
  45. /**
  46. * @var AgaviRequestDataHolder A request data holder with arguments.
  47. @@ -296,7 +296,8 @@
  48. // run the execution filter, without a proper chain
  49. $controller->getFilter('execution')->execute(new AgaviFilterChain(), $this);
  50. } else {
  51. - $this->requestData = clone $request->getRequestData();
  52. + // mmmh I smell awesomeness... clone the RD JIT, yay, that's the spirit
  53. + $this->requestData = clone $this->requestData;
  54.  
  55. if($this->arguments !== null) {
  56. $this->requestData->merge($this->arguments);
  57. @@ -400,12 +401,25 @@
  58. * @author David Zülke <dz@bitxtender.com>
  59. * @since 0.11.0
  60. */
  61. - public function getRequestData()
  62. + public final function getRequestData()
  63. {
  64. return $this->requestData;
  65. }
  66.  
  67. /**
  68. + * Set this container's request data holder instance.
  69. + *
  70. + * @param AgaviRequestDataHolder The request data holder.
  71. + *
  72. + * @author David Zülke <dz@bitxtender.com>
  73. + * @since 0.11.0
  74. + */
  75. + public final function setRequestData(AgaviRequestDataHolder $rd)
  76. + {
  77. + $this->requestData = $rd;
  78. + }
  79. +
  80. + /**
  81. * Get this container's request data holder instance for additional arguments.
  82. *
  83. * @return AgaviRequestDataHolder The additional arguments.
  84. Index: controller/AgaviSoapController.class.php
  85. ===================================================================
  86. --- controller/AgaviSoapController.class.php (revision 2101)
  87. +++ controller/AgaviSoapController.class.php (working copy)
  88. @@ -99,6 +99,8 @@
  89. */
  90. public function startup()
  91. {
  92. + parent::startup();
  93. +
  94. // user-supplied "wsdl" and "options" parameters
  95. $wsdl = $this->getParameter('wsdl');
  96. if(!$wsdl) {
  97. Index: request/AgaviXmlrpcepiphpRequest.class.php
  98. ===================================================================
  99. --- request/AgaviXmlrpcepiphpRequest.class.php (revision 2101)
  100. +++ request/AgaviXmlrpcepiphpRequest.class.php (working copy)
  101. @@ -54,20 +54,19 @@
  102. }
  103.  
  104. $rdhc = $this->getParameter('request_data_holder_class');
  105. - $this->requestData = new $rdhc(array(
  106. - constant("$rdhc::SOURCE_PARAMETERS") => array(),
  107. + $rd = new $rdhc(array(
  108. + constant("$rdhc::SOURCE_PARAMETERS") => (array)$decoded,
  109. ));
  110.  
  111. -
  112. - $this->requestData->setParameters((array)$decoded);
  113. -
  114. $split = explode(':', $this->invokedMethod);
  115. if(count($split) == 2) {
  116. - $this->requestData->setParameter($this->getParameter('module_accessor'), $split[0]);
  117. - $this->requestData->setParameter($this->getParameter('action_accessor'), $split[1]);
  118. + $rd->setParameter($this->getParameter('module_accessor'), $split[0]);
  119. + $rd->setParameter($this->getParameter('action_accessor'), $split[1]);
  120. } else {
  121. - $this->requestData->setParameter($this->getParameter('action_accessor'), $this->invokedMethod);
  122. + $rd->setParameter($this->getParameter('action_accessor'), $this->invokedMethod);
  123. }
  124. +
  125. + $this->setRequestData($rd);
  126. }
  127. }
  128.  
  129. Index: request/AgaviWebRequest.class.php
  130. ===================================================================
  131. --- request/AgaviWebRequest.class.php (revision 2101)
  132. +++ request/AgaviWebRequest.class.php (working copy)
  133. @@ -378,12 +378,12 @@
  134. }
  135.  
  136. $rdhc = $this->getParameter('request_data_holder_class');
  137. - $this->requestData = new $rdhc(array(
  138. + $this->setRequestData(new $rdhc(array(
  139. constant("$rdhc::SOURCE_PARAMETERS") => array_merge($_GET, $_POST),
  140. constant("$rdhc::SOURCE_COOKIES") => $_COOKIE,
  141. constant("$rdhc::SOURCE_FILES") => $_FILES,
  142. constant("$rdhc::SOURCE_HEADERS") => $headers,
  143. - ));
  144. + )));
  145. }
  146.  
  147. /**
  148. Index: request/AgaviRequest.class.php
  149. ===================================================================
  150. --- request/AgaviRequest.class.php (revision 2101)
  151. +++ request/AgaviRequest.class.php (working copy)
  152. @@ -54,13 +54,12 @@
  153. /**
  154. * @var AgaviRequestDataHolder The request data holder instance.
  155. */
  156. - protected $requestData = null;
  157. + private $requestData = null;
  158.  
  159. /**
  160. - * @var bool A boolean value indicating whether or not the request is
  161. - * locked.
  162. + * @var string The key used to lock the request, or null if no lock set
  163. */
  164. - private $locked = false;
  165. + private $key = null;
  166.  
  167. /**
  168. * Retrieve the current application context.
  169. @@ -173,21 +172,34 @@
  170. }
  171.  
  172. /**
  173. + * Set the data holder instance of this request.
  174. + *
  175. + * @param AgaviRequestDataHolder The request data holder.
  176. + *
  177. + * @author David Zülke <dz@bitxtender.com>
  178. + * @author Dominik del Bondio <ddb@bitxtender.com>
  179. + * @since 0.11.0
  180. + */
  181. + final protected function setRequestData(AgaviRequestDataHolder $rd)
  182. + {
  183. + if(!$this->isLocked()) {
  184. + $this->requestData = $rd;
  185. + }
  186. + }
  187. +
  188. + /**
  189. * Get the data holder instance of this request.
  190. *
  191. * @return AgaviRequestDataHolder The request data holder.
  192. *
  193. + * @author David Zülke <dz@bitxtender.com>
  194. * @author Dominik del Bondio <ddb@bitxtender.com>
  195. * @since 0.11.0
  196. */
  197. - public function getRequestData()
  198. + final public function getRequestData()
  199. {
  200. - if($this->locked) {
  201. - if($this->getParameter('request_lock_barf', true)) {
  202. - 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.");
  203. - } else {
  204. - return new AgaviRequestDataHolder();
  205. - }
  206. + if($this->isLocked()) {
  207. + 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.");
  208. }
  209. return $this->requestData;
  210. }
  211. @@ -222,7 +234,7 @@
  212. */
  213. public final function isLocked()
  214. {
  215. - return $this->locked;
  216. + return $this->key !== null;
  217. }
  218.  
  219. /**
  220. @@ -239,13 +251,12 @@
  221. */
  222. public final function toggleLock($key = null)
  223. {
  224. - static $keys = array();
  225. - if(!$this->locked && $key === null) {
  226. + if(!$this->isLocked() && $key === null) {
  227. $this->locked = true;
  228. - return $this->keys[$this->context->getName()] = uniqid();
  229. - } elseif($this->locked) {
  230. - if(isset($this->keys[$this->context->getName()]) && $this->keys[$this->context->getName()] == $key) {
  231. - $this->locked = false;
  232. + return $this->key = uniqid();
  233. + } elseif($this->isLocked()) {
  234. + if($this->key === $key) {
  235. + $this->key = null;
  236. return true;
  237. }
  238. return false;
  239. Index: request/AgaviSoapRequest.class.php
  240. ===================================================================
  241. --- request/AgaviSoapRequest.class.php (revision 2101)
  242. +++ request/AgaviSoapRequest.class.php (working copy)
  243. @@ -62,10 +62,10 @@
  244. parent::initialize($context, $parameters);
  245.  
  246. $rdhc = $this->getParameter('request_data_holder_class');
  247. - $this->requestData = new $rdhc(array(
  248. + $this->setRequestData(new $rdhc(array(
  249. constant("$rdhc::SOURCE_PARAMETERS") => array(),
  250. constant("$rdhc::SOURCE_HEADERS") => array(),
  251. - ));
  252. + )));
  253.  
  254. $this->setMethod($this->getParameter('default_method', 'read'));
  255. }
Add Comment
Please, Sign In to add comment