diff --git a/app/src/Controller/MatchgridsController.php b/app/src/Controller/MatchgridsController.php index 83e3bf0b6..5c455c824 100644 --- a/app/src/Controller/MatchgridsController.php +++ b/app/src/Controller/MatchgridsController.php @@ -227,16 +227,16 @@ public function reconcile(string $id) { throw new \RuntimeException(__('match.er.args', ['reconcile'])); } - $results = $MatchService->getRequest($rowId); + $request = $MatchService->getRequest($rowId); $candidates = []; - if($results->count() == 0) { + if($request->count() == 0) { // No such request ID throw new \RuntimeException(__('match.er.reconcile.notfound', [$rowId])); } // Parse the original request - $origReq = $results->getRawResults(); + $origReq = $request->getRawResults(); if(!empty($origReq[$rowId]['referenceId'])) { // This is a resolved request @@ -252,7 +252,7 @@ public function reconcile(string $id) { // another interface to AttributeManager for the moment. $AttributeManager = new \App\Lib\Match\AttributeManager(); // We have an array but parseFromJSON wants an object - $AttributeManager->parseFromJSON(json_decode(json_encode($results->getResultsForJson('current')))); + $AttributeManager->parseFromJSON(json_decode(json_encode($request->getResultsForJson('current')))); $results = $MatchService->searchReferenceId($sor, $sorid, $AttributeManager); diff --git a/app/src/Lib/Identifier/Sequence.php b/app/src/Lib/Identifier/Sequence.php index 5081e5b5e..9ce1fdbf0 100644 --- a/app/src/Lib/Identifier/Sequence.php +++ b/app/src/Lib/Identifier/Sequence.php @@ -29,6 +29,8 @@ namespace App\Lib\Identifier; +use Cake\ORM\TableRegistry; + class Sequence extends ReferenceIdService { /** * Generate a Reference Identifier. @@ -41,7 +43,7 @@ class Sequence extends ReferenceIdService { */ public function generate(\App\Model\Entity\Matchgrid $mgConfig, \ADOConnection $dbc) { - $MatchgridSettings = Cake\Datasource\FactoryLocator::get('Table')->get('MatchgridSettings'); + $MatchgridSettings = TableRegistry::getTableLocator()->get('MatchgridSettings'); // We'll use the matchgrid ID rather than name in the sequence name to avoid // issues if the matchgrid is renamed for some reason. diff --git a/app/src/Lib/Match/AttributeManager.php b/app/src/Lib/Match/AttributeManager.php index ed13c5bcc..f7037e402 100644 --- a/app/src/Lib/Match/AttributeManager.php +++ b/app/src/Lib/Match/AttributeManager.php @@ -211,7 +211,7 @@ public function parseFromJSON(\stdClass $json) { if(is_array($vobject) && !empty($vobject['type'])) { $g = $vobject['type']; } elseif(!empty($vobject->type)) { - $g = !empty($vobject->type); + $g = $vobject->type; } foreach($vobject as $vk => $vv) { diff --git a/app/src/Lib/Match/MatchService.php b/app/src/Lib/Match/MatchService.php index cc5ddcd44..ef7a569cd 100644 --- a/app/src/Lib/Match/MatchService.php +++ b/app/src/Lib/Match/MatchService.php @@ -30,7 +30,7 @@ namespace App\Lib\Match; use Cake\Log\Log; -use Cake\Datasource\FactoryLocator; +use Cake\ORM\TableRegistry; use \App\Lib\Enum\ConfidenceModeEnum; use \App\Lib\Enum\ReferenceIdEnum; @@ -104,7 +104,7 @@ public function attachReferenceId(string $sor, string $sorid, AttributeManager $ */ protected function generateReferenceId() { - $MatchgridSettings = FactoryLocator::get('Table')->get('MatchgridSettings'); + $MatchgridSettings = TableRegistry::getTableLocator()->get('MatchgridSettings'); if($MatchgridSettings->getReferenceIdMethod($this->mgConfig->id) == ReferenceIdEnum::Sequence) { $IdService = new \App\Lib\Identifier\Sequence; @@ -773,7 +773,7 @@ public function searchReferenceId(string $sor, string $sorid, AttributeManager $ */ public function setConfig(int $matchgridId) { - $Matchgrids = FactoryLocator::get('Table')->get('Matchgrids'); + $Matchgrids = TableRegistry::getTableLocator()->get('Matchgrids'); $this->mgConfig = $Matchgrids->findById($matchgridId) ->where(['status' => StatusEnum::Active]) diff --git a/app/src/Lib/Traits/MatchgridLinkTrait.php b/app/src/Lib/Traits/MatchgridLinkTrait.php index af52cae15..56141f857 100644 --- a/app/src/Lib/Traits/MatchgridLinkTrait.php +++ b/app/src/Lib/Traits/MatchgridLinkTrait.php @@ -29,7 +29,7 @@ namespace App\Lib\Traits; -use Cake\Datasource\FactoryLocator; +use Cake\ORM\TableRegistry; trait MatchgridLinkTrait { // Does the associated model require a matchgrid ID? @@ -79,8 +79,8 @@ public function calculateMatchgridId(int $id) { // Look up $linkAttr to get its Matchgrid. We currently assume only // one level of nesting. - $linkTable = FactoryLocator::get('Table')->get($this->getPrimaryLinkTableName()); - + $linkTable = TableRegistry::getTableLocator()->get($this->getPrimaryLinkTableName()); + return $linkTable->calculateMatchgridId($obj->$linkAttr); } } diff --git a/app/src/Model/Table/ApiUsersTable.php b/app/src/Model/Table/ApiUsersTable.php index e6400d345..7007d4132 100644 --- a/app/src/Model/Table/ApiUsersTable.php +++ b/app/src/Model/Table/ApiUsersTable.php @@ -31,7 +31,7 @@ use Cake\ORM\RulesChecker; use Cake\ORM\Table; -use Cake\Datasource\FactoryLocator; +use Cake\ORM\TableRegistry; use Cake\Validation\Validator; use \App\Lib\Enum\ResolutionModeEnum; @@ -122,7 +122,7 @@ public function checkUsername(\App\Model\Entity\ApiUser $entity, array $options) if($entity->matchgrid_id) { // This is a Matchgrid API user, so make sure it is prefixed with the matchgrid name - $matchgrids = FactoryLocator::get('Table')->get('Matchgrids'); + $matchgrids = TableRegistry::getTableLocator()->get('Matchgrids'); // This throws Cake\Datasource\Exception\RecordNotFoundException if not found $matchgrid = $matchgrids->get($entity->matchgrid_id); diff --git a/app/src/Model/Table/MatchgridRecordsTable.php b/app/src/Model/Table/MatchgridRecordsTable.php index 898e3ba51..9d0c057ae 100644 --- a/app/src/Model/Table/MatchgridRecordsTable.php +++ b/app/src/Model/Table/MatchgridRecordsTable.php @@ -30,7 +30,7 @@ namespace App\Model\Table; use Cake\ORM\Table; -use Cake\Datasource\FactoryLocator; +use Cake\ORM\TableRegistry; class MatchgridRecordsTable extends Table { use \App\Lib\Traits\AutoViewVarsTrait; @@ -67,7 +67,7 @@ public function initialize(array $config): void { // Use the matchgrid ID to figure out the attribute configuration for // search filter purposes - $Matchgrid = FactoryLocator::get('Table')->get('Matchgrids'); + $Matchgrid = TableRegistry::getTableLocator()->get('Matchgrids'); $mgconfig = $Matchgrid->getMatchgridConfig($config['matchgrid_id']);