. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Repositories; use Espo\Core\Name\Field; use Espo\Entities\Sms as SmsEntity; use Espo\Entities\PhoneNumber; use Espo\Core\Repositories\Database; /** * @extends Database<\Espo\Entities\Sms> */ class Sms extends Database { public function loadFromField(SmsEntity $entity): void { if ($entity->get('fromPhoneNumberName')) { $entity->set('from', $entity->get('fromPhoneNumberName')); return; } $numberId = $entity->get('fromPhoneNumberId'); if ($numberId) { $phoneNumber = $this->entityManager ->getRepository(PhoneNumber::ENTITY_TYPE) ->getById($numberId); if ($phoneNumber) { $entity->set('from', $phoneNumber->get(Field::NAME)); return; } } $entity->set('from', null); } public function loadToField(SmsEntity $entity): void { $entity->loadLinkMultipleField('toPhoneNumbers'); $names = $entity->get('toPhoneNumbersNames'); if (empty($names)) { $entity->set('to', null); return; } $list = []; foreach ($names as $address) { $list[] = $address; } $entity->set('to', implode(';', $list)); } }