diff --git a/application/Espo/Repositories/ArrayValue.php b/application/Espo/Repositories/ArrayValue.php index bd857aacc4..84c87ce608 100644 --- a/application/Espo/Repositories/ArrayValue.php +++ b/application/Espo/Repositories/ArrayValue.php @@ -29,6 +29,7 @@ namespace Espo\Repositories; +use Espo\Core\ORM\Entity as CoreEntity; use Espo\ORM\Entity; use Espo\Core\{ @@ -40,7 +41,7 @@ class ArrayValue extends Database { protected $hooksDisabled = true; - public function storeEntityAttribute(Entity $entity, string $attribute, bool $populateMode = false): void + public function storeEntityAttribute(CoreEntity $entity, string $attribute, bool $populateMode = false): void { if (!$entity->getAttributeType($attribute) === Entity::JSON_ARRAY) { throw new Error("ArrayValue: Can't store non array attribute."); @@ -83,7 +84,7 @@ class ArrayValue extends Database ->select(['id', 'value']) ->where([ 'entityType' => $entity->getEntityType(), - 'entityId' => $entity->id, + 'entityId' => $entity->getId(), 'attribute' => $attribute, ]) ->forUpdate() @@ -91,7 +92,7 @@ class ArrayValue extends Database foreach ($existingList as $existing) { if (!in_array($existing->get('value'), $valueList)) { - $this->deleteFromDb($existing->id); + $this->deleteFromDb($existing->getId()); continue; } @@ -113,7 +114,7 @@ class ArrayValue extends Database $arrayValue->set([ 'entityType' => $entity->getEntityType(), - 'entityId' => $entity->id, + 'entityId' => $entity->getId(), 'attribute' => $attribute, 'value' => $value, ]); @@ -126,9 +127,9 @@ class ArrayValue extends Database } } - public function deleteEntityAttribute(Entity $entity, string $attribute): void + public function deleteEntityAttribute(CoreEntity $entity, string $attribute): void { - if (!$entity->id) { + if (!$entity->getId()) { throw new Error("ArrayValue: Can't delete {$attribute} w/o id given."); } @@ -138,14 +139,14 @@ class ArrayValue extends Database ->select(['id']) ->where([ 'entityType' => $entity->getEntityType(), - 'entityId' => $entity->id, + 'entityId' => $entity->getId(), 'attribute' => $attribute, ]) ->forUpdate() ->find(); foreach ($list as $arrayValue) { - $this->deleteFromDb($arrayValue->id); + $this->deleteFromDb($arrayValue->getId()); } $this->entityManager->getTransactionManager()->commit(); diff --git a/application/Espo/Repositories/Attachment.php b/application/Espo/Repositories/Attachment.php index 43bc97672a..bec3a55684 100644 --- a/application/Espo/Repositories/Attachment.php +++ b/application/Espo/Repositories/Attachment.php @@ -33,11 +33,17 @@ use Espo\ORM\Entity; use Espo\Entities\Attachment as AttachmentEntity; +use Espo\Core\Repositories\Database; + use Espo\Core\Di; use Psr\Http\Message\StreamInterface; -class Attachment extends \Espo\Core\Repositories\Database implements +/** + * @template T of \Espo\Entities\Attachment + * @extends Database<\Espo\Entities\Attachment> + */ +class Attachment extends Database implements Di\FileManagerAware, Di\FileStorageManagerAware, Di\ConfigAware @@ -92,6 +98,9 @@ class Attachment extends \Espo\Core\Repositories\Database implements $this->fileStorageManager->putContents($entity, $contents); } + /** + * @param AttachmentEntity $entity + */ protected function afterRemove(Entity $entity, array $options = []) { parent::afterRemove($entity, $options);