|
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_XmlRpc |
|
17 * @subpackage Client |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: ServerProxy.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 |
|
24 /** |
|
25 * The namespace decorator enables object chaining to permit |
|
26 * calling XML-RPC namespaced functions like "foo.bar.baz()" |
|
27 * as "$remote->foo->bar->baz()". |
|
28 * |
|
29 * @category Zend |
|
30 * @package Zend_XmlRpc |
|
31 * @subpackage Client |
|
32 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
33 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
34 */ |
|
35 class Zend_XmlRpc_Client_ServerProxy |
|
36 { |
|
37 /** |
|
38 * @var Zend_XmlRpc_Client |
|
39 */ |
|
40 private $_client = null; |
|
41 |
|
42 /** |
|
43 * @var string |
|
44 */ |
|
45 private $_namespace = ''; |
|
46 |
|
47 |
|
48 /** |
|
49 * @var array of Zend_XmlRpc_Client_ServerProxy |
|
50 */ |
|
51 private $_cache = array(); |
|
52 |
|
53 |
|
54 /** |
|
55 * Class constructor |
|
56 * |
|
57 * @param string $namespace |
|
58 * @param Zend_XmlRpc_Client $client |
|
59 */ |
|
60 public function __construct($client, $namespace = '') |
|
61 { |
|
62 $this->_namespace = $namespace; |
|
63 $this->_client = $client; |
|
64 } |
|
65 |
|
66 |
|
67 /** |
|
68 * Get the next successive namespace |
|
69 * |
|
70 * @param string $name |
|
71 * @return Zend_XmlRpc_Client_ServerProxy |
|
72 */ |
|
73 public function __get($namespace) |
|
74 { |
|
75 $namespace = ltrim("$this->_namespace.$namespace", '.'); |
|
76 if (!isset($this->_cache[$namespace])) { |
|
77 $this->_cache[$namespace] = new $this($this->_client, $namespace); |
|
78 } |
|
79 return $this->_cache[$namespace]; |
|
80 } |
|
81 |
|
82 |
|
83 /** |
|
84 * Call a method in this namespace. |
|
85 * |
|
86 * @param string $methodN |
|
87 * @param array $args |
|
88 * @return mixed |
|
89 */ |
|
90 public function __call($method, $args) |
|
91 { |
|
92 $method = ltrim("$this->_namespace.$method", '.'); |
|
93 return $this->_client->call($method, $args); |
|
94 } |
|
95 } |