<?php
 namespace App\ImportedOrder; class Passenger_Title extends EntityAbstract { public $codeTina; public $codeSystem; protected function validateEntityFields(\App\MessagesCollector $messagesCollector): void { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); if ($this->codeTina and !in_array($this->codeTina, $CFG['generalData']['personTitles'])) { $messagesCollector->addInfo('The passenger title TINA code is not valid'); } } public function getMatchedId($idExternalSystem) { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $matchedCodes = []; if ($this->codeTina and in_array($this->codeTina, $CFG['generalData']['personTitles'])) { $matchedCodes[$this->codeTina] = true; } if ($this->codeSystem and $idExternalSystem) { $matchedTitle = \App\Config\ImportedOrders_Matches::getInstance()->getCustomerTitle($idExternalSystem, $this->codeSystem); if ($matchedTitle) { $matchedCodes[$matchedTitle] = true; } } if (count($matchedCodes)==1) { return key($matchedCodes); } else { return false; } } }