Skip to content

Commit

Permalink
Issue #36: Improve Source::parseXml().
Browse files Browse the repository at this point in the history
  • Loading branch information
ademarco committed Oct 5, 2017
1 parent 878f4f3 commit d14b12a
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/Messages/Components/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,25 +300,39 @@ protected function parseXml($xml)
{
$parser = $this->getParser();
$parser->addXmlContent($xml);
$this->parseDocumentSource($parser);
$this->parseSourceLanguage($parser);

$this->setChannel($parser->getAttribute('documentSource', 'channel'))
->setDeadline($parser->getAttribute('documentSource', 'deadline'))
->setDeadlineStatus($parser->getAttribute('documentSource', 'statusDeadline'))
->setConfidential($parser->getAttribute('documentSource', 'marked'))
->setFormat($parser->getAttribute('documentSource', 'format'))
->setLegiswriteFormat($parser->getAttribute('documentSource', 'legiswrite'))
->setTrackChanges($parser->getAttribute('documentSource', 'trackChanges'))
->setName($parser->getContent('documentSource/documentSourceName'))
->setPath($parser->getContent('documentSource/documentSourcePath'))
->setSize($parser->getContent('documentSource/documentSourceSize'))
->setFile($parser->getContent('documentSource/documentSourceFile'));
return $this;
}

/**
* @param \EC\Poetry\Services\Parser $parser
*/
private function parseSourceLanguage(Parser $parser)
{
$parser->eachComponent("documentSource/documentSourceLang", function (Parser $language) {
$this->withSourceLanguage()
->setParser($this->getParser())
->fromXml($language->outerHtml());
->setParser($this->getParser())
->fromXml($language->outerHtml());
}, $this);
}

return $this;
/**
* @param \EC\Poetry\Services\Parser $parser
*/
private function parseDocumentSource(Parser $parser)
{
$this->setChannel($parser->getAttribute('documentSource', 'channel'))
->setDeadline($parser->getAttribute('documentSource', 'deadline'))
->setDeadlineStatus($parser->getAttribute('documentSource', 'statusDeadline'))
->setConfidential($parser->getAttribute('documentSource', 'marked'))
->setFormat($parser->getAttribute('documentSource', 'format'))
->setLegiswriteFormat($parser->getAttribute('documentSource', 'legiswrite'))
->setTrackChanges($parser->getAttribute('documentSource', 'trackChanges'))
->setName($parser->getContent('documentSource/documentSourceName'))
->setPath($parser->getContent('documentSource/documentSourcePath'))
->setSize($parser->getContent('documentSource/documentSourceSize'))
->setFile($parser->getContent('documentSource/documentSourceFile'));
}
}

0 comments on commit d14b12a

Please sign in to comment.