-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #380 from cgoedel/working-at-withdraw-request
Implement working atEppWithdrawRequest
- Loading branch information
Showing
1 changed file
with
69 additions
and
18 deletions.
There are no files selected for viewing
87 changes: 69 additions & 18 deletions
87
Protocols/EPP/eppExtensions/at-ext-epp-1.0/eppRequests/atEppWithdrawRequest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,89 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: martinha | ||
* Date: 10/04/2019 | ||
* Time: 09:17 | ||
*/ | ||
/** @noinspection PhpMissingReturnTypeInspection */ | ||
|
||
namespace Metaregistrar\EPP; | ||
|
||
use DomElement; | ||
use DOMException; | ||
|
||
/** | ||
* Class atEppWithdrawRequest works only as adapter in order to map a atEppResponse. | ||
* | ||
* @author [email protected] | ||
* @package Metaregistrar\EPP | ||
* | ||
*/ | ||
class atEppWithdrawRequest extends eppRequest | ||
{ | ||
/** | ||
* atEppWithdrawRequest constructor. | ||
* @param $arguments | ||
* | ||
* @throws \atEppException | ||
* @throws DOMException | ||
*/ | ||
public function __construct($arguments) | ||
public function __construct(eppDomain $domain, bool $zoneDelete = false) | ||
{ | ||
$this->validateArguments($arguments); | ||
parent::__construct(); | ||
|
||
$domainZd = $this->createElement('domain:zd'); | ||
$domainZd->setAttribute('value', intval($zoneDelete)); | ||
|
||
$domainWithdraw = $this->createElement('domain:withdraw'); | ||
$domainWithdraw->setAttribute('xmlns:domain', atEppConstants::namespaceAtExtDomain); | ||
$domainWithdraw->setAttribute('xsi:schemaLocation', atEppConstants::schemaLocationAtExtDomain); | ||
$domainWithdraw->appendChild($this->createElement('domain:name', $domain->getDomainname())); | ||
$domainWithdraw->appendChild($domainZd); | ||
|
||
$withdraw = $this->createElement('withdraw'); | ||
$withdraw->appendChild($domainWithdraw); | ||
|
||
$this->getCommand()->appendChild($withdraw); | ||
$this->addSessionId(); | ||
} | ||
|
||
protected function validateArguments($arguments) | ||
/** | ||
* Needs to be overwritten, because relation of extension and command is inverted in withdraw command. | ||
* | ||
* @return DomElement | ||
* @throws DOMException | ||
*/ | ||
public function getExtension() | ||
{ | ||
if (! key_exists('domain_name', $arguments) || ! key_exists('zone_deletion', $arguments)) | ||
{ | ||
throw new \atEppException( | ||
'atEppWithdrawRequest requires two arguments domain_name:string and zone_deletion:boolean.'); | ||
if (!$this->extension) { | ||
# | ||
# If it's not there, then create extension structure | ||
# | ||
$this->extension = $this->createElement('extension'); | ||
$this->getEpp()->appendChild($this->extension); | ||
} | ||
return $this->extension; | ||
} | ||
|
||
|
||
/** | ||
* Get the command element of the epp structure. | ||
* Needs to be overwritten, because relation of extension and command is inverted in withdraw command. | ||
* | ||
* @return DomElement | ||
* @throws DOMException | ||
*/ | ||
protected function getCommand() { | ||
if (!$this->command) { | ||
# | ||
# If it's not there, then create command structure | ||
# | ||
$this->command = $this->createElement('command'); | ||
$this->command->setAttribute('xmlns', atEppConstants::namespaceAtExt); | ||
$this->command->setAttribute('xsi:schemaLocation', atEppConstants::schemaLocationAtExt); | ||
$this->getExtension()->appendChild($this->command); | ||
} | ||
return $this->command; | ||
} | ||
|
||
/** | ||
* Get the epp element of the epp structure | ||
* Overwrite necessary because error occurs if 'xmlns:xsi' attribute is not supplied. | ||
* | ||
* @return DomElement | ||
*/ | ||
public function getEpp() { | ||
parent::getEpp()->setAttribute('xmlns:xsi', atEppConstants::w3SchemaLocation); | ||
return $this->epp; | ||
} | ||
} |