Add method to fetch list of workflows to workflow storage

[MAILPOET-4287]
This commit is contained in:
Jan Jakes
2022-04-27 13:25:44 +02:00
committed by Veljko V
parent 1b46765f47
commit 47c5111996
2 changed files with 11 additions and 1 deletions

View File

@@ -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);