sms status update

This commit is contained in:
Yuri Kuznetsov
2022-01-05 11:19:33 +02:00
parent 150e41a26d
commit a730f47ceb
2 changed files with 15 additions and 0 deletions
@@ -77,12 +77,18 @@ class SendType extends BaseFunction implements
try {
$this->createSender()->send($sms);
$this->entityManager->saveEntity($sms);
}
catch (Exception $e) {
$message = $e->getMessage();
$this->log("Error while sending SMS. Message: {$message}." , 'error');
$sms->setStatus(Sms::STATUS_FAILED);
$this->entityManager->saveEntity($sms);
return false;
}
+9
View File
@@ -47,6 +47,8 @@ class Sms extends Entity implements SmsInterface
public const STATUS_DRAFT = 'Draft';
public const STATUS_FAILED = 'Failed';
public function getDateSent(): ?DateTime
{
return $this->getValueObject('dateTime');
@@ -135,6 +137,13 @@ class Sms extends Entity implements SmsInterface
return $this;
}
public function setStatus(string $status): self
{
$this->set('status', $status);
return $this;
}
private function getSmsRepository(): SmsRepository
{
/** @var SmsRepository */