From 901e0967fca20eb66a1595f3cbc69ee81cddd8d0 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 3 Nov 2021 11:17:47 +0200 Subject: [PATCH] type fixes --- application/Espo/Tools/Import/Import.php | 21 ++++++++++--------- application/Espo/Tools/Kanban/Kanban.php | 2 +- .../Espo/Tools/Kanban/OrdererProcessor.php | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/application/Espo/Tools/Import/Import.php b/application/Espo/Tools/Import/Import.php index 6dce727e7c..0c816fb550 100644 --- a/application/Espo/Tools/Import/Import.php +++ b/application/Espo/Tools/Import/Import.php @@ -359,7 +359,7 @@ class Import $this->entityManager->createEntity('ImportEntity', [ 'entityType' => $this->entityType, 'entityId' => $rowResult->id, - 'importId' => $import->id, + 'importId' => $import->getId(), 'isImported' => $rowResult->isImported ?? false, 'isUpdated' => $rowResult->isUpdated ?? false, 'isDuplicate' => $rowResult->isDuplicate ?? false, @@ -421,7 +421,7 @@ class Import } $entity = $this->entityManager - ->getRepository($this->entityType) + ->getRDBRepository($this->entityType) ->where($whereClause) ->findOne(); @@ -448,6 +448,8 @@ class Import $entity = $this->entityManager->getEntity($this->entityType); } + assert($entity instanceof Entity); + $isNew = $entity->isNew(); $entity->set($params->getDefaultValues()); @@ -501,8 +503,7 @@ class Import } if ( - $entity->getAttributeType($attribute) === Entity::FOREIGN - && + $entity->getAttributeType($attribute) === Entity::FOREIGN && $entity->getAttributeParam($attribute, 'foreign') === 'name' ) { $this->processForeignName($entity, $attribute); @@ -519,10 +520,10 @@ class Import } } - if ($entity->id) { + if ($entity->getId()) { $this->entityManager - ->getRepository($entity->getEntityType()) - ->deleteFromDb($entity->id, true); + ->getRDBRepository($entity->getEntityType()) + ->deleteFromDb($entity->getId(), true); } try { @@ -533,7 +534,7 @@ class Import 'silent' => $params->isSilentMode(), ]); - $result['id'] = $entity->id; + $result['id'] = $entity->getId(); if ($isNew) { $result['isImported'] = true; @@ -607,13 +608,13 @@ class Import } $found = $this->entityManager - ->getRepository($foreignEntityType) + ->getRDBRepository($foreignEntityType) ->select(['id', 'name']) ->where($where) ->findOne(); if ($found) { - $entity->set($relation . 'Id', $found->id); + $entity->set($relation . 'Id', $found->getId()); $entity->set($relation . 'Name', $found->get('name')); return; diff --git a/application/Espo/Tools/Kanban/Kanban.php b/application/Espo/Tools/Kanban/Kanban.php index 08115dc841..a26cb09fc1 100644 --- a/application/Espo/Tools/Kanban/Kanban.php +++ b/application/Espo/Tools/Kanban/Kanban.php @@ -178,7 +178,7 @@ class Kanban 'groupList' => [], ]; - $repository = $this->entityManager->getRepository($this->entityType); + $repository = $this->entityManager->getRDBRepository($this->entityType); foreach ($statusList as $status) { if (in_array($status, $statusIgnoreList)) { diff --git a/application/Espo/Tools/Kanban/OrdererProcessor.php b/application/Espo/Tools/Kanban/OrdererProcessor.php index 74ed280a35..dbbf49f644 100644 --- a/application/Espo/Tools/Kanban/OrdererProcessor.php +++ b/application/Espo/Tools/Kanban/OrdererProcessor.php @@ -125,7 +125,7 @@ class OrdererProcessor $minOrder = null; $first = $this->entityManager - ->getRepository('KanbanOrder') + ->getRDBRepository('KanbanOrder') ->select(['id', 'order']) ->where([ 'entityType' => $this->entityType,