Rename step runner to handler (free the name to step runner interface)
[MAILPOET-4515]
This commit is contained in:
@@ -15,7 +15,7 @@ use MailPoet\Automation\Engine\Workflows\StepRunner as StepRunnerInterface;
|
|||||||
use MailPoet\Automation\Engine\Workflows\WorkflowRun;
|
use MailPoet\Automation\Engine\Workflows\WorkflowRun;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class StepRunner {
|
class StepHandler {
|
||||||
/** @var ActionScheduler */
|
/** @var ActionScheduler */
|
||||||
private $actionScheduler;
|
private $actionScheduler;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ class StepRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function initialize(): void {
|
public function initialize(): void {
|
||||||
$this->wordPress->addAction(Hooks::WORKFLOW_STEP, [$this, 'run']);
|
$this->wordPress->addAction(Hooks::WORKFLOW_STEP, [$this, 'handle']);
|
||||||
$this->addStepRunner(Step::TYPE_ACTION, $this->actionStepRunner);
|
$this->addStepRunner(Step::TYPE_ACTION, $this->actionStepRunner);
|
||||||
$this->wordPress->doAction(Hooks::STEP_RUNNER_INITIALIZE, [$this]);
|
$this->wordPress->doAction(Hooks::STEP_RUNNER_INITIALIZE, [$this]);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ class StepRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @param mixed $args */
|
/** @param mixed $args */
|
||||||
public function run($args): void {
|
public function handle($args): void {
|
||||||
// TODO: args validation
|
// TODO: args validation
|
||||||
if (!is_array($args)) {
|
if (!is_array($args)) {
|
||||||
throw new InvalidStateException();
|
throw new InvalidStateException();
|
||||||
@@ -68,7 +68,7 @@ class StepRunner {
|
|||||||
// Action Scheduler catches only Exception instances, not other errors.
|
// Action Scheduler catches only Exception instances, not other errors.
|
||||||
// We need to convert them to exceptions to be processed and logged.
|
// We need to convert them to exceptions to be processed and logged.
|
||||||
try {
|
try {
|
||||||
$this->runStep($args);
|
$this->handleStep($args);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
$this->workflowRunStorage->updateStatus((int)$args['workflow_run_id'], WorkflowRun::STATUS_FAILED);
|
$this->workflowRunStorage->updateStatus((int)$args['workflow_run_id'], WorkflowRun::STATUS_FAILED);
|
||||||
if (!$e instanceof Exception) {
|
if (!$e instanceof Exception) {
|
||||||
@@ -78,7 +78,7 @@ class StepRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function runStep(array $args): void {
|
private function handleStep(array $args): void {
|
||||||
$workflowRunId = $args['workflow_run_id'];
|
$workflowRunId = $args['workflow_run_id'];
|
||||||
$stepId = $args['step_id'];
|
$stepId = $args['step_id'];
|
||||||
|
|
@@ -3,7 +3,7 @@
|
|||||||
namespace MailPoet\Automation\Engine;
|
namespace MailPoet\Automation\Engine;
|
||||||
|
|
||||||
use MailPoet\Automation\Engine\API\API;
|
use MailPoet\Automation\Engine\API\API;
|
||||||
use MailPoet\Automation\Engine\Control\StepRunner;
|
use MailPoet\Automation\Engine\Control\StepHandler;
|
||||||
use MailPoet\Automation\Engine\Control\TriggerHandler;
|
use MailPoet\Automation\Engine\Control\TriggerHandler;
|
||||||
use MailPoet\Automation\Engine\Endpoints\System\DatabaseDeleteEndpoint;
|
use MailPoet\Automation\Engine\Endpoints\System\DatabaseDeleteEndpoint;
|
||||||
use MailPoet\Automation\Engine\Endpoints\System\DatabasePostEndpoint;
|
use MailPoet\Automation\Engine\Endpoints\System\DatabasePostEndpoint;
|
||||||
@@ -25,8 +25,8 @@ class Engine {
|
|||||||
/** @var Registry */
|
/** @var Registry */
|
||||||
private $registry;
|
private $registry;
|
||||||
|
|
||||||
/** @var StepRunner */
|
/** @var StepHandler */
|
||||||
private $stepRunner;
|
private $stepHandler;
|
||||||
|
|
||||||
/** @var TriggerHandler */
|
/** @var TriggerHandler */
|
||||||
private $triggerHandler;
|
private $triggerHandler;
|
||||||
@@ -41,7 +41,7 @@ class Engine {
|
|||||||
API $api,
|
API $api,
|
||||||
CoreIntegration $coreIntegration,
|
CoreIntegration $coreIntegration,
|
||||||
Registry $registry,
|
Registry $registry,
|
||||||
StepRunner $stepRunner,
|
StepHandler $stepHandler,
|
||||||
TriggerHandler $triggerHandler,
|
TriggerHandler $triggerHandler,
|
||||||
WordPress $wordPress,
|
WordPress $wordPress,
|
||||||
WorkflowStorage $workflowStorage
|
WorkflowStorage $workflowStorage
|
||||||
@@ -49,7 +49,7 @@ class Engine {
|
|||||||
$this->api = $api;
|
$this->api = $api;
|
||||||
$this->coreIntegration = $coreIntegration;
|
$this->coreIntegration = $coreIntegration;
|
||||||
$this->registry = $registry;
|
$this->registry = $registry;
|
||||||
$this->stepRunner = $stepRunner;
|
$this->stepHandler = $stepHandler;
|
||||||
$this->triggerHandler = $triggerHandler;
|
$this->triggerHandler = $triggerHandler;
|
||||||
$this->wordPress = $wordPress;
|
$this->wordPress = $wordPress;
|
||||||
$this->workflowStorage = $workflowStorage;
|
$this->workflowStorage = $workflowStorage;
|
||||||
@@ -59,7 +59,7 @@ class Engine {
|
|||||||
$this->registerApiRoutes();
|
$this->registerApiRoutes();
|
||||||
|
|
||||||
$this->api->initialize();
|
$this->api->initialize();
|
||||||
$this->stepRunner->initialize();
|
$this->stepHandler->initialize();
|
||||||
$this->triggerHandler->initialize();
|
$this->triggerHandler->initialize();
|
||||||
|
|
||||||
$this->coreIntegration->register($this->registry);
|
$this->coreIntegration->register($this->registry);
|
||||||
|
@@ -114,7 +114,7 @@ class ContainerConfigurator implements IContainerConfigurator {
|
|||||||
$container->autowire(\MailPoet\Automation\Engine\Builder\UpdateStepsController::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Builder\UpdateStepsController::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Builder\UpdateWorkflowController::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Builder\UpdateWorkflowController::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\ActionScheduler::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\ActionScheduler::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\StepRunner::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\StepHandler::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\SubjectLoader::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\SubjectLoader::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\Steps\ActionStepRunner::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\Steps\ActionStepRunner::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Control\TriggerHandler::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Control\TriggerHandler::class)->setPublic(true);
|
||||||
|
Reference in New Issue
Block a user