Add step run controller to allow actions control their flow
[MAILPOET-5569]
This commit is contained in:
33
mailpoet/lib/Automation/Engine/Control/StepRunController.php
Normal file
33
mailpoet/lib/Automation/Engine/Control/StepRunController.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace MailPoet\Automation\Engine\Control;
|
||||||
|
|
||||||
|
use MailPoet\Automation\Engine\Data\StepRunArgs;
|
||||||
|
|
||||||
|
class StepRunController {
|
||||||
|
/** @var StepScheduler */
|
||||||
|
private $stepScheduler;
|
||||||
|
|
||||||
|
/** @var StepRunArgs */
|
||||||
|
private $stepRunArgs;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
StepScheduler $stepScheduler,
|
||||||
|
StepRunArgs $stepRunArgs
|
||||||
|
) {
|
||||||
|
$this->stepScheduler = $stepScheduler;
|
||||||
|
$this->stepRunArgs = $stepRunArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scheduleProgress(int $timestamp = null): int {
|
||||||
|
return $this->stepScheduler->scheduleProgress($this->stepRunArgs, $timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scheduleNextStep(int $timestamp = null): int {
|
||||||
|
return $this->stepScheduler->scheduleNextStep($this->stepRunArgs, $timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasScheduledNextStep(): bool {
|
||||||
|
return $this->stepScheduler->hasScheduledNextStep($this->stepRunArgs);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,20 @@
|
|||||||
|
<?php declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace MailPoet\Automation\Engine\Control;
|
||||||
|
|
||||||
|
use MailPoet\Automation\Engine\Data\StepRunArgs;
|
||||||
|
|
||||||
|
class StepRunControllerFactory {
|
||||||
|
/** @var StepScheduler */
|
||||||
|
private $stepScheduler;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
StepScheduler $stepScheduler
|
||||||
|
) {
|
||||||
|
$this->stepScheduler = $stepScheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createController(StepRunArgs $args): StepRunController {
|
||||||
|
return new StepRunController($this->stepScheduler, $args);
|
||||||
|
}
|
||||||
|
}
|
@@ -126,6 +126,7 @@ class ContainerConfigurator implements IContainerConfigurator {
|
|||||||
$container->autowire(\MailPoet\Automation\Engine\Control\RootStep::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\RootStep::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\FilterHandler::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\FilterHandler::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\StepHandler::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\StepHandler::class)->setPublic(true);
|
||||||
|
$container->autowire(\MailPoet\Automation\Engine\Control\StepRunControllerFactory::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\StepScheduler::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\StepScheduler::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\SubjectTransformerHandler::class)->setPublic(true)->setShared(false);
|
$container->autowire(\MailPoet\Automation\Engine\Control\SubjectTransformerHandler::class)->setPublic(true)->setShared(false);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\SubjectLoader::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\SubjectLoader::class)->setPublic(true);
|
||||||
|
Reference in New Issue
Block a user