Command.php 1.79 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php

	/**
	* @package Net_EPP
	*/
	class Net_EPP_Frame_Command extends Net_EPP_Frame {

		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);

maryoflaherty's avatar
maryoflaherty committed
17
			if (isset($this->type)) {
18
19
20
21
				$this->payload = $this->createElementNS(
					Net_EPP_ObjectSpec::xmlns($this->type),
					$this->type.':'.$command
				);
22

23
24
				$this->command->appendChild($this->payload);
			}
25
26

			$this->clTRID = $this->createElement('clTRID');
maryoflaherty's avatar
maryoflaherty committed
27
			$this->clTRID->appendChild($this->createTextNode(''));
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
			$this->body->appendChild($this->clTRID);
		}

		function addObjectProperty($name, $value=NULL) {
			debug_log("%s::%s(%s, %s)", __CLASS__, __FUNCTION__, $name, $value);
			$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;
		}

		function createObjectPropertyElement($name) {
			return $this->createElementNS(
				Net_EPP_ObjectSpec::xmlns($this->type),
				$this->type.':'.$name
			);
		}

53
54
55
56
57
58
59
60
61
62
63
		function createExtensionElement($ext, $command) {
			$this->extension = $this->createElement('extension');
			$this->body->appendChild($this->extension);

			$this->extension->payload = $this->createElementNS(
				Net_EPP_ObjectSpec::xmlns($ext),
				$ext.':'.$command
			);

			$this->extension->appendChild($this->extension->payload);
		}
64
65
	}
?>