Persist all possible subject on run creation

[MAILPOET-4935]
This commit is contained in:
David Remer
2023-03-20 08:58:07 +02:00
committed by Aschepikov
parent c968b03ca7
commit d365be2334
2 changed files with 58 additions and 8 deletions

View File

@@ -29,15 +29,20 @@ class TriggerHandler {
/** @var AutomationRunStorage */
private $automationRunStorage;
/** @var Functions */
private $wp;
/** @var SubjectTransformerHandler */
private $subjectTransformerHandler;
public function __construct(
ActionScheduler $actionScheduler,
SubjectLoader $subjectLoader,
WordPress $wordPress,
AutomationStorage $automationStorage,
AutomationRunStorage $automationRunStorage,
Functions $wp
Functions $wp,
SubjectTransformerHandler $subjectTransformerHandler
) {
$this->actionScheduler = $actionScheduler;
$this->wordPress = $wordPress;
@@ -45,6 +50,7 @@ class TriggerHandler {
$this->automationRunStorage = $automationRunStorage;
$this->subjectLoader = $subjectLoader;
$this->wp = $wp;
$this->subjectTransformerHandler = $subjectTransformerHandler;
}
public function initialize(): void {
@@ -53,6 +59,7 @@ class TriggerHandler {
/** @param Subject[] $subjects */
public function processTrigger(Trigger $trigger, array $subjects): void {
$subjects = $this->subjectTransformerHandler->provideAllSubjects($trigger, ...$subjects);
$automations = $this->automationStorage->getActiveAutomationsByTrigger($trigger);
foreach ($automations as $automation) {
$step = $automation->getTrigger($trigger->getKey());