1
1
<?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: martinha
5
- * Date: 10/04/2019
6
- * Time: 09:17
7
- */
2
+ /** @noinspection PhpMissingReturnTypeInspection */
8
3
9
4
namespace Metaregistrar \EPP ;
10
5
6
+ use DomElement ;
7
+ use DOMException ;
8
+
11
9
/**
12
- * Class atEppWithdrawRequest works only as adapter in order to map a atEppResponse.
13
10
*
11
+
14
12
* @package Metaregistrar\EPP
13
+ *
15
14
*/
16
15
class atEppWithdrawRequest extends eppRequest
17
16
{
18
17
/**
19
- * atEppWithdrawRequest constructor.
20
- * @param $arguments
21
- *
22
- * @throws \atEppException
18
+ * @throws DOMException
23
19
*/
24
- public function __construct ($ arguments )
20
+ public function __construct (eppDomain $ domain , bool $ zoneDelete = false )
25
21
{
26
- $ this ->validateArguments ($ arguments );
27
22
parent ::__construct ();
23
+
24
+ $ domainZd = $ this ->createElement ('domain:zd ' );
25
+ $ domainZd ->setAttribute ('value ' , intval ($ zoneDelete ));
26
+
27
+ $ domainWithdraw = $ this ->createElement ('domain:withdraw ' );
28
+ $ domainWithdraw ->setAttribute ('xmlns:domain ' , atEppConstants::namespaceAtExtDomain);
29
+ $ domainWithdraw ->setAttribute ('xsi:schemaLocation ' , atEppConstants::schemaLocationAtExtDomain);
30
+ $ domainWithdraw ->appendChild ($ this ->createElement ('domain:name ' , $ domain ->getDomainname ()));
31
+ $ domainWithdraw ->appendChild ($ domainZd );
32
+
33
+ $ withdraw = $ this ->createElement ('withdraw ' );
34
+ $ withdraw ->appendChild ($ domainWithdraw );
35
+
36
+ $ this ->getCommand ()->appendChild ($ withdraw );
37
+ $ this ->addSessionId ();
28
38
}
29
39
30
- protected function validateArguments ($ arguments )
40
+ /**
41
+ * Needs to be overwritten, because relation of extension and command is inverted in withdraw command.
42
+ *
43
+ * @return DomElement
44
+ * @throws DOMException
45
+ */
46
+ public function getExtension ()
31
47
{
32
- if (! key_exists ('domain_name ' , $ arguments ) || ! key_exists ('zone_deletion ' , $ arguments ))
33
- {
34
- throw new \atEppException (
35
- 'atEppWithdrawRequest requires two arguments domain_name:string and zone_deletion:boolean. ' );
48
+ if (!$ this ->extension ) {
49
+ #
50
+ # If it's not there, then create extension structure
51
+ #
52
+ $ this ->extension = $ this ->createElement ('extension ' );
53
+ $ this ->getEpp ()->appendChild ($ this ->extension );
36
54
}
55
+ return $ this ->extension ;
56
+ }
57
+
58
+
59
+ /**
60
+ * Get the command element of the epp structure.
61
+ * Needs to be overwritten, because relation of extension and command is inverted in withdraw command.
62
+ *
63
+ * @return DomElement
64
+ * @throws DOMException
65
+ */
66
+ protected function getCommand () {
67
+ if (!$ this ->command ) {
68
+ #
69
+ # If it's not there, then create command structure
70
+ #
71
+ $ this ->command = $ this ->createElement ('command ' );
72
+ $ this ->command ->setAttribute ('xmlns ' , atEppConstants::namespaceAtExt);
73
+ $ this ->command ->setAttribute ('xsi:schemaLocation ' , atEppConstants::schemaLocationAtExt);
74
+ $ this ->getExtension ()->appendChild ($ this ->command );
75
+ }
76
+ return $ this ->command ;
77
+ }
78
+
79
+ /**
80
+ * Get the epp element of the epp structure
81
+ * Overwrite necessary because error occurs if 'xmlns:xsi' attribute is not supplied.
82
+ *
83
+ * @return DomElement
84
+ */
85
+ public function getEpp () {
86
+ parent ::getEpp ()->setAttribute ('xmlns:xsi ' , atEppConstants::w3SchemaLocation);
87
+ return $ this ->epp ;
37
88
}
38
89
}
0 commit comments