From b88e310f7ebd44a57d2f1b575e2ca041a465e87c Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Mon, 7 Mar 2022 12:01:54 +0100 Subject: [PATCH] Add storage service for workflow runs & create workflow run method [MAILPOET-4136] --- .../Engine/Storage/WorkflowRunStorage.php | 29 +++++++++++++++++++ mailpoet/lib/DI/ContainerConfigurator.php | 1 + 2 files changed, 30 insertions(+) create mode 100644 mailpoet/lib/Automation/Engine/Storage/WorkflowRunStorage.php diff --git a/mailpoet/lib/Automation/Engine/Storage/WorkflowRunStorage.php b/mailpoet/lib/Automation/Engine/Storage/WorkflowRunStorage.php new file mode 100644 index 0000000000..5e5c5df1d9 --- /dev/null +++ b/mailpoet/lib/Automation/Engine/Storage/WorkflowRunStorage.php @@ -0,0 +1,29 @@ +table = $wpdb->prefix . 'mailpoet_automation_workflow_runs'; + $this->wpdb = $wpdb; + } + + public function createWorkflowRun(WorkflowRun $workflowRun): int { + $result = $this->wpdb->insert($this->table, $workflowRun->toArray()); + if ($result === false) { + throw Exceptions::databaseError($this->wpdb->last_error); + } + return $this->wpdb->insert_id; + } +} diff --git a/mailpoet/lib/DI/ContainerConfigurator.php b/mailpoet/lib/DI/ContainerConfigurator.php index 822d6ac52a..e336bd4b1b 100644 --- a/mailpoet/lib/DI/ContainerConfigurator.php +++ b/mailpoet/lib/DI/ContainerConfigurator.php @@ -112,6 +112,7 @@ class ContainerConfigurator implements IContainerConfigurator { $container->autowire(\MailPoet\Automation\Engine\Engine::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\Migrations\Migrator::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\Registry::class)->setPublic(true); + $container->autowire(\MailPoet\Automation\Engine\Storage\WorkflowRunStorage::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\Storage\WorkflowStorage::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\WordPress::class)->setPublic(true); // Config