|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| - /** |
4 |
| - * @package Net_EPP |
5 |
| - */ |
6 |
| - class Net_EPP_Frame_Command extends Net_EPP_Frame { |
| 3 | + /** |
| 4 | + * @package Net_EPP |
| 5 | + */ |
| 6 | + class Net_EPP_Frame_Command extends Net_EPP_Frame |
| 7 | + { |
| 8 | + public function __construct($command, $type = "") |
| 9 | + { |
| 10 | + $this->type = $type; |
| 11 | + $command = strtolower($command); |
| 12 | + if (!in_array($command, array('check', 'info', 'create', 'update', 'delete', 'renew', 'transfer', 'poll', 'login', 'logout'))) { |
| 13 | + trigger_error("Invalid argument value '$command' for \$command", E_USER_ERROR); |
| 14 | + } |
| 15 | + parent::__construct('command'); |
7 | 16 |
|
8 |
| - function __construct($command, $type="") { |
9 |
| - $this->type = $type; |
10 |
| - $command = strtolower($command); |
11 |
| - if (!in_array($command, array('check', 'info', 'create', 'update', 'delete', 'renew', 'transfer', 'poll', 'login', 'logout'))) trigger_error("Invalid argument value '$command' for \$command", E_USER_ERROR); |
12 |
| - parent::__construct('command'); |
| 17 | + $this->command = $this->createElement($command); |
| 18 | + $this->body->appendChild($this->command); |
13 | 19 |
|
14 |
| - $this->command = $this->createElement($command); |
15 |
| - $this->body->appendChild($this->command); |
| 20 | + if (!empty($this->type)) { |
| 21 | + $this->payload = $this->createElementNS( |
| 22 | + Net_EPP_ObjectSpec::xmlns($this->type), |
| 23 | + $this->type.':'.$command |
| 24 | + ); |
16 | 25 |
|
17 |
| - if (!empty($this->type)) { |
18 |
| - $this->payload = $this->createElementNS( |
19 |
| - Net_EPP_ObjectSpec::xmlns($this->type), |
20 |
| - $this->type.':'.$command |
21 |
| - ); |
| 26 | + $this->command->appendChild($this->payload); |
| 27 | + } |
| 28 | + } |
22 | 29 |
|
23 |
| - $this->command->appendChild($this->payload); |
24 |
| - } |
25 |
| - } |
| 30 | + public function addclTRID($id) |
| 31 | + { |
| 32 | + $this->clTRID = $this->createElement('clTRID'); |
| 33 | + $this->clTRID->appendChild($this->createTextNode($id)); |
| 34 | + $this->body->appendChild($this->clTRID); |
| 35 | + } |
26 | 36 |
|
27 |
| - function addclTRID($id) { |
28 |
| - $this->clTRID = $this->createElement('clTRID'); |
29 |
| - $this->clTRID->appendChild($this->createTextNode($id)); |
30 |
| - $this->body->appendChild($this->clTRID); |
31 |
| - } |
| 37 | + public function addObjectProperty($name, $value = null) |
| 38 | + { |
| 39 | + $element = $this->createObjectPropertyElement($name); |
| 40 | + $this->payload->appendChild($element); |
32 | 41 |
|
33 |
| - function addObjectProperty($name, $value=NULL) { |
34 |
| - $element = $this->createObjectPropertyElement($name); |
35 |
| - $this->payload->appendChild($element); |
| 42 | + if ($value instanceof DomNode) { |
| 43 | + $element->appendChild($value); |
| 44 | + } elseif (isset($value)) { |
| 45 | + $element->appendChild($this->createTextNode($value)); |
| 46 | + } |
| 47 | + return $element; |
| 48 | + } |
36 | 49 |
|
37 |
| - if ($value instanceof DomNode) { |
38 |
| - $element->appendChild($value); |
| 50 | + public function createObjectPropertyElement($name, $type = null) |
| 51 | + { |
| 52 | + $ns_type = isset($type) ? $type : $this->type; |
| 53 | + $ns = !empty($ns_type) ? $ns_type.':'.$name : $name; |
| 54 | + return $this->createElementNS( |
| 55 | + Net_EPP_ObjectSpec::xmlns($ns_type), |
| 56 | + $ns |
| 57 | + ); |
| 58 | + } |
39 | 59 |
|
40 |
| - } elseif (isset($value)) { |
41 |
| - $element->appendChild($this->createTextNode($value)); |
42 |
| - |
43 |
| - } |
44 |
| - return $element; |
45 |
| - } |
46 |
| - |
47 |
| - function createObjectPropertyElement($name, $type=NULL) { |
48 |
| - $ns_type = isset($type) ? $type : $this->type; |
49 |
| - $ns = !empty($ns_type) ? $ns_type.':'.$name : $name; |
50 |
| - return $this->createElementNS( |
51 |
| - Net_EPP_ObjectSpec::xmlns($ns_type), $ns |
52 |
| - ); |
53 |
| - } |
54 |
| - |
55 |
| - function createExtension() { |
56 |
| - $this->extension = $this->createElement('extension'); |
57 |
| - $this->body->appendChild($this->extension); |
58 |
| - } |
| 60 | + public function createExtension() |
| 61 | + { |
| 62 | + $this->extension = $this->createElement('extension'); |
| 63 | + $this->body->appendChild($this->extension); |
| 64 | + } |
59 | 65 |
|
60 | 66 | /**
|
61 |
| - * Creates an extension element with the option of specifying a custom namespace |
| 67 | + * Creates an extension element with the option of specifying a custom namespace |
62 | 68 | * @param $ext
|
63 | 69 | * @param $command
|
64 |
| - * @param null $version * |
| 70 | + * @param null $version * |
65 | 71 | */
|
66 |
| - function createExtensionElement($ext, $command, $version=null) { |
67 |
| - $this->extension->payload = $this->createElementNS( |
68 |
| - Net_EPP_ObjectSpec::xmlns($version !== null ? $version : $ext), |
69 |
| - $ext.':'.$command |
70 |
| - ); |
71 |
| - $this->extension->appendChild($this->extension->payload); |
72 |
| - } |
73 |
| - |
74 |
| - } |
75 |
| -?> |
| 72 | + public function createExtensionElement($ext, $command, $version = null) |
| 73 | + { |
| 74 | + $this->extension->payload = $this->createElementNS( |
| 75 | + Net_EPP_ObjectSpec::xmlns($version !== null ? $version : $ext), |
| 76 | + $ext.':'.$command |
| 77 | + ); |
| 78 | + $this->extension->appendChild($this->extension->payload); |
| 79 | + } |
| 80 | + } |
0 commit comments