diff --git a/src/Messages/Components/Source.php b/src/Messages/Components/Source.php index e9782ef..2282d0c 100644 --- a/src/Messages/Components/Source.php +++ b/src/Messages/Components/Source.php @@ -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')); } }