2
0

OnlineProxy.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_Service_Simpy
  17. * @subpackage UnitTests
  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. * @version $Id$
  21. */
  22. require_once 'BaseProxy.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Service_Simpy
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. */
  30. class Zend_Service_Simpy_OnlineProxy extends Zend_Service_Simpy_BaseProxy
  31. {
  32. /**
  33. * Proxy all method calls to the service consumer object and write
  34. * responses to local files, regardless of whether service calls result
  35. * in an exception being thrown.
  36. *
  37. * @param string $name Name of the method called
  38. * @param array $args Arguments passed in the method call
  39. * @return mixed Return value of the called method
  40. */
  41. public function __call($name, array $args)
  42. {
  43. sleep(3);
  44. try {
  45. $return = call_user_func_array(
  46. array($this->_simpy, $name),
  47. $args
  48. );
  49. } catch (Exception $e) { }
  50. $response = $this->_simpy
  51. ->getHttpClient()
  52. ->getLastResponse()
  53. ->getBody();
  54. $file = $this->_getFilePath($name);
  55. file_put_contents($file, $response);
  56. if (isset($e)) {
  57. throw $e;
  58. }
  59. return $return;
  60. }
  61. }