<?php
namespace App\Apollo\StructureParser\Structures\EMD; class Relations extends \App\Galileo\StructureParser\Structures\Base\Base { protected function _getData() { list($parsedStructure, $transactionType, $transactionIndexes, $internalAssociations) = $this->getTransactionDetails(); $item = new \App\Apollo\StructureParser\Types\Relations(); $relation = new \App\Apollo\StructureParser\Types\Relation(); $relations = []; for ($k30 = 0; $k30 < count($parsedStructure['A30']); ++$k30) { $a30 = $parsedStructure['A30'][$k30]; $k = $a30['A30']['A30ATK_ticketNumber']; ++$relations[$k]['count']; $relations[$k]['A30ATK_ticketNumber'] = $a30['A30']['A30ATK_ticketNumber']; } if (1 != count($relations)) { $this->transaction->getMessagesCollector()->addWarning(sprintf('%s: we got more than 1 related ticket. Only the first one will be used.', __METHOD__)); } $r = reset($relations); $relation->docNumber = $r['A30ATK_ticketNumber']; $relation->relationType = 'reference'; $item->appendRelation($relation); return $item; } } 