-
Notifications
You must be signed in to change notification settings - Fork 25
/
Command.php
executable file
·80 lines (70 loc) · 2.7 KB
/
Command.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* @package Net_EPP
*/
class Net_EPP_Frame_Command extends Net_EPP_Frame
{
public function __construct($command, $type = "")
{
$this->type = $type;
$command = strtolower($command);
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);
}
parent::__construct('command');
$this->command = $this->createElement($command);
$this->body->appendChild($this->command);
if (!empty($this->type)) {
$this->payload = $this->createElementNS(
Net_EPP_ObjectSpec::xmlns($this->type),
$this->type.':'.$command
);
$this->command->appendChild($this->payload);
}
}
public function addclTRID($id)
{
$this->clTRID = $this->createElement('clTRID');
$this->clTRID->appendChild($this->createTextNode($id));
$this->body->appendChild($this->clTRID);
}
public function addObjectProperty($name, $value = null)
{
$element = $this->createObjectPropertyElement($name);
$this->payload->appendChild($element);
if ($value instanceof DomNode) {
$element->appendChild($value);
} elseif (isset($value)) {
$element->appendChild($this->createTextNode($value));
}
return $element;
}
public function createObjectPropertyElement($name, $type = null)
{
$ns_type = isset($type) ? $type : $this->type;
$ns = !empty($ns_type) ? $ns_type.':'.$name : $name;
return $this->createElementNS(
Net_EPP_ObjectSpec::xmlns($ns_type),
$ns
);
}
public function createExtension()
{
$this->extension = $this->createElement('extension');
$this->body->appendChild($this->extension);
}
/**
* Creates an extension element with the option of specifying a custom namespace
* @param $ext
* @param $command
* @param null $version *
*/
public function createExtensionElement($ext, $command, $version = null)
{
$this->extension->payload = $this->createElementNS(
Net_EPP_ObjectSpec::xmlns($version !== null ? $version : $ext),
$ext.':'.$command
);
$this->extension->appendChild($this->extension->payload);
}
}