Skip to content

Commit

Permalink
Issue #36: Improve Target:parseXml().
Browse files Browse the repository at this point in the history
  • Loading branch information
ademarco committed Oct 5, 2017
1 parent d14b12a commit 9a34cb9
Showing 1 changed file with 44 additions and 23 deletions.
67 changes: 44 additions & 23 deletions src/Messages/Components/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,38 +310,59 @@ protected function parseXml($xml)
{
$parser = $this->getParser();
$parser->addXmlContent($xml);
$this->parseAttributionContact($parser);
$this->parseAttributionsSend($parser);
$this->parseAttributions($parser);

return $this;
}

/**
* @param \EC\Poetry\Services\Parser $parser
*/
private function parseAttributionContact(Parser $parser)
{
$parser->eachComponent("attributions/attributionContact", function (Parser $component) {
$this->withContact()
->setParser($this->getParser())
->setNickname($component->getContent('attributionContact/contactNickname'))
->setEmail($component->getContent('attributionContact/contactEmail'))
->setType($component->attr('type'))
->setAction($component->attr('action'));
->setParser($this->getParser())
->setNickname($component->getContent('attributionContact/contactNickname'))
->setEmail($component->getContent('attributionContact/contactEmail'))
->setType($component->attr('type'))
->setAction($component->attr('action'));
}, $this);
}

/**
* @param \EC\Poetry\Services\Parser $parser
*/
private function parseAttributionsSend(Parser $parser)
{
$parser->eachComponent("attributions/attributionsSend", function (Parser $component) {
$this->withReturnAddress()
->setParser($this->getParser())
->setType($component->attr('type'))
->setAction($component->attr('action'))
->setUser($component->getContent('attributionsSend/retourUser'))
->setPassword($component->getContent('attributionsSend/retourPassword'))
->setAddress($component->getContent('attributionsSend/retourAddress'))
->setPath($component->getContent('attributionsSend/retourPath'))
->setRemark($component->getContent('attributionsSend/retourRemark'));
->setParser($this->getParser())
->setType($component->attr('type'))
->setAction($component->attr('action'))
->setUser($component->getContent('attributionsSend/retourUser'))
->setPassword($component->getContent('attributionsSend/retourPassword'))
->setAddress($component->getContent('attributionsSend/retourAddress'))
->setPath($component->getContent('attributionsSend/retourPath'))
->setRemark($component->getContent('attributionsSend/retourRemark'));
}, $this);
}

/**
* @param \EC\Poetry\Services\Parser $parser
*/
private function parseAttributions(Parser $parser)
{
$this->setFormat($parser->getAttribute('attributions', 'format'))
->setLanguage($parser->getAttribute('attributions', 'lgCode'))
->setTrackChanges($parser->getAttribute('attributions', 'trackChanges'))
->setRemark($parser->getContent('attributions/attributionsRemark'))
->setDelay($parser->getContent('attributions/attributionsDelai'))
->setDelayFormat($parser->getAttribute('attributions/attributionsDelai', 'format'))
->setAcceptedDelay($parser->getContent('attributions/attributionsDelaiAccepted'))
->setAcceptedDelayFormat($parser->getAttribute('attributions/attributionsDelaiAccepted', 'format'))
->setTranslatedFile($parser->getContent('attributions/attributionsFile'));

return $this;
->setLanguage($parser->getAttribute('attributions', 'lgCode'))
->setTrackChanges($parser->getAttribute('attributions', 'trackChanges'))
->setRemark($parser->getContent('attributions/attributionsRemark'))
->setDelay($parser->getContent('attributions/attributionsDelai'))
->setDelayFormat($parser->getAttribute('attributions/attributionsDelai', 'format'))
->setAcceptedDelay($parser->getContent('attributions/attributionsDelaiAccepted'))
->setAcceptedDelayFormat($parser->getAttribute('attributions/attributionsDelaiAccepted', 'format'))
->setTranslatedFile($parser->getContent('attributions/attributionsFile'));
}
}

0 comments on commit 9a34cb9

Please sign in to comment.