Store run subjects in extra table
[MAILPOET-4966]
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace MailPoet\Automation\Engine\Data;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use MailPoet\Automation\Engine\Utils\Json;
|
||||
|
||||
class AutomationRun {
|
||||
public const STATUS_RUNNING = 'running';
|
||||
@@ -107,11 +106,9 @@ class AutomationRun {
|
||||
'status' => $this->status,
|
||||
'created_at' => $this->createdAt->format(DateTimeImmutable::W3C),
|
||||
'updated_at' => $this->updatedAt->format(DateTimeImmutable::W3C),
|
||||
'subjects' => Json::encode(
|
||||
array_map(function (Subject $subject): array {
|
||||
'subjects' => array_map(function (Subject $subject): array {
|
||||
return $subject->toArray();
|
||||
}, $this->subjects)
|
||||
),
|
||||
}, $this->subjects),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -122,7 +119,7 @@ class AutomationRun {
|
||||
$data['trigger_key'],
|
||||
array_map(function (array $subject) {
|
||||
return Subject::fromArray($subject);
|
||||
}, Json::decode($data['subjects']))
|
||||
}, $data['subjects'])
|
||||
);
|
||||
$automationRun->id = (int)$data['id'];
|
||||
$automationRun->status = $data['status'];
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace MailPoet\Automation\Engine\Data;
|
||||
|
||||
use MailPoet\Automation\Engine\Utils\Json;
|
||||
|
||||
class Subject {
|
||||
/** @var string */
|
||||
private $key;
|
||||
@@ -28,11 +30,11 @@ class Subject {
|
||||
public function toArray(): array {
|
||||
return [
|
||||
'key' => $this->getKey(),
|
||||
'args' => $this->getArgs(),
|
||||
'args' => Json::encode($this->getArgs()),
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): self {
|
||||
return new self($data['key'], $data['args']);
|
||||
return new self($data['key'], Json::decode($data['args']));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user