Add workflow name editing capability
[MAILPOET-4422]
This commit is contained in:
@ -27,6 +27,12 @@ class UpdateWorkflowController {
|
||||
throw Exceptions::workflowNotFound($id);
|
||||
}
|
||||
|
||||
if (array_key_exists('name', $data)) {
|
||||
$this->checkWorkflowName($data['name']);
|
||||
$workflow->setName($data['name']);
|
||||
$this->storage->updateWorkflow($workflow);
|
||||
}
|
||||
|
||||
if (array_key_exists('status', $data)) {
|
||||
$this->checkWorkflowStatus($data['status']);
|
||||
$workflow->setStatus($data['status']);
|
||||
@ -40,6 +46,12 @@ class UpdateWorkflowController {
|
||||
return $workflow;
|
||||
}
|
||||
|
||||
private function checkWorkflowName(string $name): void {
|
||||
if (empty($name)) {
|
||||
throw UnexpectedValueException::create()->withMessage(__('Workflow name must not be empty', 'mailpoet'));
|
||||
}
|
||||
}
|
||||
|
||||
private function checkWorkflowStatus(string $status): void {
|
||||
if (!in_array($status, [Workflow::STATUS_ACTIVE, Workflow::STATUS_INACTIVE, Workflow::STATUS_DRAFT], true)) {
|
||||
throw UnexpectedValueException::create()->withMessage(__(sprintf('Invalid status: %s', $status), 'mailpoet'));
|
||||
|
Reference in New Issue
Block a user