From 067765d9b508cd14d6c3cdf2f52b2df699f6f112 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 16 Sep 2024 16:24:23 +0300 Subject: [PATCH] ref --- .../FieldProcessing/EmailAddress/Saver.php | 8 +++--- .../FieldProcessing/PhoneNumber/Saver.php | 8 +++--- application/Espo/Entities/EmailAddress.php | 14 ++++++++++ application/Espo/Entities/PhoneNumber.php | 28 +++++++++++++++++++ 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php b/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php index ad7a3c5724..09c2035323 100644 --- a/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php +++ b/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php @@ -280,8 +280,8 @@ class Saver implements SaverInterface $this->entityManager->saveEntity($emailAddress); } else { $revertData[$address] = [ - 'optOut' => $emailAddress->get('optOut'), - 'invalid' => $emailAddress->get('invalid'), + 'optOut' => $emailAddress->isOptedOut(), + 'invalid' => $emailAddress->isInvalid(), ]; } } @@ -470,14 +470,14 @@ class Saver implements SaverInterface /** @var EmailAddress $emailAddressNew */ $emailAddressNew = $this->entityManager->getNewEntity(EmailAddress::ENTITY_TYPE); - $emailAddressNew->set('name', $emailAddressValue); + $emailAddressNew->setAddress($emailAddressValue); if ($entity->has(self::ATTR_EMAIL_ADDRESS_IS_OPTED_OUT)) { $emailAddressNew->setOptedOut((bool) $entity->get(self::ATTR_EMAIL_ADDRESS_IS_OPTED_OUT)); } if ($entity->has(self::ATTR_EMAIL_ADDRESS_IS_INVALID)) { - $emailAddressNew->set('invalid', (bool) $entity->get(self::ATTR_EMAIL_ADDRESS_IS_INVALID)); + $emailAddressNew->setInvalid((bool) $entity->get(self::ATTR_EMAIL_ADDRESS_IS_INVALID)); } $this->entityManager->saveEntity($emailAddressNew); diff --git a/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php b/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php index 3ff74a69b1..2f7716dfe0 100644 --- a/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php +++ b/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php @@ -511,20 +511,20 @@ class Saver implements SaverInterface /** @var PhoneNumber $phoneNumberNew */ $phoneNumberNew = $this->entityManager->getNewEntity(PhoneNumber::ENTITY_TYPE); - $phoneNumberNew->set('name', $phoneNumberValue); + $phoneNumberNew->setNumber($phoneNumberValue); if ($entity->has(self::ATTR_PHONE_NUMBER_IS_OPTED_OUT)) { - $phoneNumberNew->set('optOut', (bool)$entity->get(self::ATTR_PHONE_NUMBER_IS_OPTED_OUT)); + $phoneNumberNew->setOptedOut((bool)$entity->get(self::ATTR_PHONE_NUMBER_IS_OPTED_OUT)); } if ($entity->has(self::ATTR_PHONE_NUMBER_IS_INVALID)) { - $phoneNumberNew->set('invalid', (bool)$entity->get(self::ATTR_PHONE_NUMBER_IS_INVALID)); + $phoneNumberNew->setInvalid((bool)$entity->get(self::ATTR_PHONE_NUMBER_IS_INVALID)); } $defaultType = $this->metadata ->get("entityDefs.{$entity->getEntityType()}.fields.phoneNumber.defaultType"); - $phoneNumberNew->set('type', $defaultType); + $phoneNumberNew->setType($defaultType); $this->entityManager->saveEntity($phoneNumberNew); } diff --git a/application/Espo/Entities/EmailAddress.php b/application/Espo/Entities/EmailAddress.php index 27701fc945..362be6f3cc 100644 --- a/application/Espo/Entities/EmailAddress.php +++ b/application/Espo/Entities/EmailAddress.php @@ -80,4 +80,18 @@ class EmailAddress extends Entity return $this; } + + public function setInvalid(bool $invalid): self + { + $this->set('invalid', $invalid); + + return $this; + } + + public function setAddress(string $address): self + { + $this->set('name', $address); + + return $this; + } } diff --git a/application/Espo/Entities/PhoneNumber.php b/application/Espo/Entities/PhoneNumber.php index 2b2f5cdccb..79f6ccc7af 100644 --- a/application/Espo/Entities/PhoneNumber.php +++ b/application/Espo/Entities/PhoneNumber.php @@ -71,5 +71,33 @@ class PhoneNumber extends Entity { return $this->get('type'); } + + public function setType(string $type): self + { + $this->set('type', $type); + + return $this; + } + + public function setNumber(string $number): self + { + $this->set('name', $number); + + return $this; + } + + public function setOptedOut(bool $optedOut): self + { + $this->set('optOut', $optedOut); + + return $this; + } + + public function setInvalid(bool $invalid): self + { + $this->set('invalid', $invalid); + + return $this; + } }