Make steps specify required/provided subject keys
[MAILPOET-4629]
This commit is contained in:
@ -17,4 +17,8 @@ class RootStep implements Step {
|
||||
public function getArgsSchema(): ObjectSchema {
|
||||
return new ObjectSchema();
|
||||
}
|
||||
|
||||
public function getSubjectKeys(): array {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,7 @@ interface Step {
|
||||
public function getName(): string;
|
||||
|
||||
public function getArgsSchema(): ObjectSchema;
|
||||
|
||||
/** @return string[] */
|
||||
public function getSubjectKeys(): array;
|
||||
}
|
||||
|
@ -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, [
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user