Add storage service for workflow runs & create workflow run method
[MAILPOET-4136]
This commit is contained in:
@ -0,0 +1,29 @@
|
|||||||
|
<?php declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace MailPoet\Automation\Engine\Storage;
|
||||||
|
|
||||||
|
use MailPoet\Automation\Engine\Exceptions;
|
||||||
|
use MailPoet\Automation\Engine\Workflows\WorkflowRun;
|
||||||
|
use wpdb;
|
||||||
|
|
||||||
|
class WorkflowRunStorage {
|
||||||
|
/** @var string */
|
||||||
|
private $table;
|
||||||
|
|
||||||
|
/** @var wpdb */
|
||||||
|
private $wpdb;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
global $wpdb;
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
@ -112,6 +112,7 @@ class ContainerConfigurator implements IContainerConfigurator {
|
|||||||
$container->autowire(\MailPoet\Automation\Engine\Engine::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\Engine::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\Migrations\Migrator::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\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\Storage\WorkflowStorage::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Automation\Engine\WordPress::class)->setPublic(true);
|
$container->autowire(\MailPoet\Automation\Engine\WordPress::class)->setPublic(true);
|
||||||
// Config
|
// Config
|
||||||
|
Reference in New Issue
Block a user