<?php
namespace App\ImportedDocument; class ImportedService extends EntityAbstract { public $idTina; public $idServiceExtSys; public $extSysCode; protected function validateEntityFields(\App\MessagesCollector $messagesCollector) { if ($this->idTina and !is_numeric($this->idTina) and $this->idTina<0) { $messagesCollector->addWarning('The TINA id must be numeric.'); } if ($this->extSysCode and !\Entity\ExtResSystem::getSystemIdByCode($this->extSysCode)) { $messagesCollector->addError('The external system code is not valid.'); } } public function getMatchedId() { $idImportedServMatched = 0; if ($this->extSysCode and $this->idServiceExtSys) { $idSystemMatched = \Entity\ExtResSystem::getSystemIdByCode($this->extSysCode); if ($idSystemMatched) { $result = \Entity\ImportedService::getDetailsByServiceExtSys($this->idServiceExtSys, $idSystemMatched, false); $idImportedServMatched = $result['id']; } } if (!$idImportedServMatched) { $return = (Int)$this->idTina; } else { if (!$this->idTina or $this->idTina==$idImportedServMatched) { $return = $idImportedServMatched; } else { $return = 0; } } return $return; } }