From 47c5111996edfbbd205f40461b453dba5265a827 Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Wed, 27 Apr 2022 13:25:44 +0200 Subject: [PATCH] Add method to fetch list of workflows to workflow storage [MAILPOET-4287] --- .../lib/Automation/Engine/Storage/WorkflowStorage.php | 10 ++++++++++ mailpoet/tasks/phpstan/phpstan.neon | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mailpoet/lib/Automation/Engine/Storage/WorkflowStorage.php b/mailpoet/lib/Automation/Engine/Storage/WorkflowStorage.php index 4109da5677..845eb4e5e7 100644 --- a/mailpoet/lib/Automation/Engine/Storage/WorkflowStorage.php +++ b/mailpoet/lib/Automation/Engine/Storage/WorkflowStorage.php @@ -36,6 +36,16 @@ class WorkflowStorage { return $data ? Workflow::fromArray((array)$data) : null; } + /** @return Workflow[] */ + public function getWorkflows(): array { + $table = esc_sql($this->table); + $query = "SELECT * FROM $table ORDER BY id DESC"; + $data = $this->wpdb->get_results($query, ARRAY_A); + return array_map(function (array $workflowData) { + return Workflow::fromArray($workflowData); + }, (array)$data); + } + /** @return string[] */ public function getActiveTriggerKeys(): array { $table = esc_sql($this->table); diff --git a/mailpoet/tasks/phpstan/phpstan.neon b/mailpoet/tasks/phpstan/phpstan.neon index 38b68aeff4..5ba7825b7a 100644 --- a/mailpoet/tasks/phpstan/phpstan.neon +++ b/mailpoet/tasks/phpstan/phpstan.neon @@ -49,7 +49,7 @@ parameters: count: 2 path: ../../lib/Automation/Engine/Storage/WorkflowRunStorage.php - - message: "#^Cannot cast string|void to string.$#" + message: "#^Cannot cast string|void to string\\.$#" count: 3 path: ../../lib/Automation/Engine/Storage/WorkflowStorage.php reportUnmatchedIgnoredErrors: true