1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AfriCC\EPP\Extension\NASK\Update; |
4
|
|
|
|
5
|
|
|
use AfriCC\EPP\ExtensionInterface; |
6
|
|
|
use AfriCC\EPP\ExtensionTrait; |
7
|
|
|
use AfriCC\EPP\Frame\Command\Update\Domain as DomainUpdate; |
8
|
|
|
use AfriCC\EPP\Validator; |
9
|
|
|
|
10
|
|
|
class Domain extends DomainUpdate implements ExtensionInterface |
11
|
|
|
{ |
12
|
|
|
use ExtensionTrait; |
13
|
|
|
|
14
|
|
|
protected $extension = 'extdom'; |
15
|
|
|
protected $extension_xmlns = 'http://www.dns.pl/nask-epp-schema/extdom-2.0'; |
16
|
|
|
|
17
|
|
|
public function addNs($host, $remove = false) |
18
|
|
|
{ |
19
|
|
|
if (!Validator::isHostname($host)) { |
20
|
|
|
throw new \Exception(sprintf('%s is not a valid host name', $host)); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
if ($remove) { |
24
|
|
|
$key = 'rem'; |
25
|
|
|
} else { |
26
|
|
|
$key = 'add'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
$this->set(sprintf('domain:%s/domain:ns[]', $key), $host); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function removeNs($host) |
33
|
|
|
{ |
34
|
|
|
return $this->addNs($host, true); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function addHostObj($host, $remove = false) |
38
|
|
|
{ |
39
|
|
|
return $this->addNs($host, $remove); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function addAdminContact($contact, $remove = false) |
43
|
|
|
{ |
44
|
|
|
if ($remove) { |
45
|
|
|
$key = 'rem'; |
46
|
|
|
} else { |
47
|
|
|
return false; //TODO: should this thow if registry forbids adding Admin contact? |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$this->set(sprintf('domain:%s/domain:contact[@type=\'admin\']', $key), $contact); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function addTechContact($contact, $remove = false) |
54
|
|
|
{ |
55
|
|
|
if ($remove) { |
56
|
|
|
$key = 'rem'; |
57
|
|
|
} else { |
58
|
|
|
return false; //TODO: shuld this throw if registry forbids adding Tech contact? |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$this->set(sprintf('domain:%s/domain:contact[@type=\'tech\']', $key), $contact); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function addBillingContact($contact, $remove = false) |
65
|
|
|
{ |
66
|
|
|
if ($remove) { |
67
|
|
|
$key = 'rem'; |
68
|
|
|
} else { |
69
|
|
|
return false; //TODO: should this throw if registry forbids adding Billing contact |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$this->set(sprintf('domain:%s/domain:contact[@type=\'billing\']', $key), $contact); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|