Make steps specify required/provided subject keys

[MAILPOET-4629]
This commit is contained in:
Jan Jakes
2022-09-19 13:40:40 +02:00
committed by David Remer
parent c28d8ad79c
commit 00e8c4f3e5
6 changed files with 30 additions and 0 deletions

View File

@ -17,4 +17,8 @@ class RootStep implements Step {
public function getArgsSchema(): ObjectSchema {
return new ObjectSchema();
}
public function getSubjectKeys(): array {
return [];
}
}

View File

@ -10,4 +10,7 @@ interface Step {
public function getName(): string;
public function getArgsSchema(): ObjectSchema;
/** @return string[] */
public function getSubjectKeys(): array;
}

View File

@ -36,6 +36,10 @@ class DelayAction implements Action {
]);
}
public function getSubjectKeys(): array {
return [];
}
public function run(Workflow $workflow, WorkflowRun $workflowRun, Step $step): void {
$nextStep = $step->getNextSteps()[0] ?? null;
$this->actionScheduler->schedule(time() + $this->calculateSeconds($step), Hooks::WORKFLOW_STEP, [

View File

@ -72,6 +72,13 @@ class SendEmailAction implements Action {
]);
}
public function getSubjectKeys(): array {
return [
'mailpoet:segment',
'mailpoet:subscriber',
];
}
public function isValid(array $subjects, Step $step, Workflow $workflow): bool {
try {
$this->getEmailForStep($step);

View File

@ -39,6 +39,13 @@ class SomeoneSubscribesTrigger implements Trigger {
]);
}
public function getSubjectKeys(): array {
return [
SubscriberSubject::KEY,
SegmentSubject::KEY,
];
}
public function registerHooks(): void {
$this->wp->addAction('mailpoet_segment_subscribed', [$this, 'handleSubscription'], 10, 2);
}

View File

@ -285,6 +285,11 @@ class TestAction implements Action {
$this->callback = $callback;
}
public function getSubjectKeys(): array {
return [];
}
public function isValid(array $subjects, Step $step, Workflow $workflow): bool {
return true;
}