mirror of
https://github.com/Karaka-Management/oms-Workflow.git
synced 2026-01-11 06:48:41 +00:00
rector fixes + bug fixes
This commit is contained in:
parent
7cf3ca1098
commit
f8b0914601
|
|
@ -369,7 +369,7 @@
|
|||
"de": "Zeitgesteuerter Trigger (Job/Task)"
|
||||
},
|
||||
"function_type": "Api",
|
||||
"function": "apiRun",
|
||||
"function": "",
|
||||
"module": "Workflow",
|
||||
"function_install": {
|
||||
"module": "Workflow",
|
||||
|
|
@ -408,7 +408,7 @@
|
|||
"de": "Konsolenbefehl"
|
||||
},
|
||||
"function_type": "Api",
|
||||
"function": "apiRun",
|
||||
"function": "",
|
||||
"module": "Workflow",
|
||||
"inputs": [
|
||||
"cmd",
|
||||
|
|
@ -443,7 +443,7 @@
|
|||
"de": "Workflow Script"
|
||||
},
|
||||
"function_type": "Api",
|
||||
"function": "apiRun",
|
||||
"function": "",
|
||||
"module": "Workflow",
|
||||
"inputs": [
|
||||
"{*}"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ return [
|
|||
'^.*/workflow/instance.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Workflow\Controller\CliController:cliWorkflowInstanceCreate',
|
||||
'verb' => RouteVerb::PUT,
|
||||
'verb' => RouteVerb::ANY,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ use Modules\Media\Models\PathSettings;
|
|||
use Modules\Workflow\Models\PermissionCategory;
|
||||
use Modules\Workflow\Models\WorkflowInstanceAbstract;
|
||||
use Modules\Workflow\Models\WorkflowInstanceAbstractMapper;
|
||||
use Modules\Workflow\Models\WorkflowStatus;
|
||||
use Modules\Workflow\Models\WorkflowTemplate;
|
||||
use Modules\Workflow\Models\WorkflowTemplateMapper;
|
||||
use phpOMS\Account\PermissionType;
|
||||
|
|
@ -497,7 +496,7 @@ final class ApiController extends Controller
|
|||
|
||||
$job->interval = $settings['settings']['interval'] ?? '';
|
||||
$job->command = 'php '
|
||||
. FileUtils::absolute(__DIR__ . '/../../../Cli/cli.php')
|
||||
. FileUtils::absolute(__DIR__ . '/../../../cli.php')
|
||||
. ' /workflow/instance -id '
|
||||
. $template->id
|
||||
. ' -trigger 1005500005';
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Modules\Workflow\Controller;
|
|||
|
||||
use Modules\Workflow\Models\WorkflowInstance;
|
||||
use Modules\Workflow\Models\WorkflowInstanceAbstract;
|
||||
use Modules\Workflow\Models\WorkflowInstanceMapper;
|
||||
use Modules\Workflow\Models\WorkflowInstanceAbstractMapper;
|
||||
use Modules\Workflow\Models\WorkflowStatus;
|
||||
use Modules\Workflow\Models\WorkflowTemplate;
|
||||
use Modules\Workflow\Models\WorkflowTemplateMapper;
|
||||
|
|
@ -60,18 +60,14 @@ final class CliController extends Controller
|
|||
$triggerIsRegex = \stripos($data['@triggerGroup'], '/') === 0;
|
||||
$matched = false;
|
||||
|
||||
if ($triggerIsRegex) {
|
||||
$matched = \preg_match($data['@triggerGroup'], $hook) === 1;
|
||||
} else {
|
||||
$matched = $data['@triggerGroup'] === $hook;
|
||||
}
|
||||
|
||||
if (!$matched && \stripos($hook, '/') === 0) {
|
||||
$matched = \preg_match($hook, $data['@triggerGroup']) === 1;
|
||||
}
|
||||
$matched = $triggerIsRegex
|
||||
? \preg_match($data['@triggerGroup'], $hook) === 1
|
||||
: $data['@triggerGroup'] === $hook;
|
||||
|
||||
if ($matched) {
|
||||
$this->runWorkflow($workflow, $hook, $data);
|
||||
} elseif (\stripos($hook, '/') === 0) {
|
||||
$matched = \preg_match($hook, $data['@triggerGroup']) === 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -116,13 +112,13 @@ final class CliController extends Controller
|
|||
$response->header->status = RequestStatusCode::R_400;
|
||||
}
|
||||
|
||||
$instance = $this->createInstanceFromRequest($request, $response);
|
||||
$this->createModel($request->header->account, $instance, WorkflowInstanceMapper::class, 'instance', $request->getOrigin());
|
||||
$instance = $this->createInstanceFromRequest($request);
|
||||
$this->createModel($request->header->account, $instance, WorkflowInstanceAbstractMapper::class, 'instance', $request->getOrigin());
|
||||
$this->startInstance($request, $response, $instance);
|
||||
|
||||
$new = clone $instance;
|
||||
$new->end = new \DateTime('now');
|
||||
$this->updateModel($request->header->account, $instance, $new, WorkflowInstanceMapper::class, 'instance', $request->getOrigin());
|
||||
$new->end = new \DateTimeImmutable('now');
|
||||
$this->updateModel($request->header->account, $instance, $new, WorkflowInstanceAbstractMapper::class, 'instance', $request->getOrigin());
|
||||
|
||||
$view->setTemplate('/Modules/Workflow/Theme/Cli/empty-command');
|
||||
|
||||
|
|
@ -141,7 +137,7 @@ final class CliController extends Controller
|
|||
private function validateInstanceCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['id'] = !$request->hasData('id'))) {
|
||||
if (($val['id'] = !$request->hasData('-id'))) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +159,7 @@ final class CliController extends Controller
|
|||
{
|
||||
/** @var \Modules\Workflow\Models\WorkflowTemplate $template */
|
||||
$template = WorkflowTemplateMapper::get()
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('id', (int) $request->getData('-id'))
|
||||
->execute();
|
||||
|
||||
$instance = new WorkflowInstance();
|
||||
|
|
@ -185,7 +181,7 @@ final class CliController extends Controller
|
|||
}
|
||||
|
||||
foreach ($instance->template->schema as $e) {
|
||||
if ($e['id'] === $request->getDataString('trigger')) {
|
||||
if ($e['id'] === $request->getDataString('-trigger')) {
|
||||
$this->runWorkflowElement($request, $response, $actions, $instance, $e);
|
||||
|
||||
break;
|
||||
|
|
@ -198,10 +194,12 @@ final class CliController extends Controller
|
|||
array $actions, WorkflowInstanceAbstract $instance, array $element
|
||||
) : void
|
||||
{
|
||||
if (isset($actions[$element['id']])) {
|
||||
if (isset($actions[(int) $element['id']])
|
||||
&& $actions[(int) $element['id']]['function'] !== ''
|
||||
) {
|
||||
$this->app->moduleManager
|
||||
->get($actions[$element['id']]['modules'], $actions[$element['id']]['function_type'])
|
||||
->{$actions[$element['id']]['function']}($request, $response, [$element]);
|
||||
->get($actions[(int) $element['id']]['module'], $actions[(int) $element['id']]['function_type'])
|
||||
->{$actions[(int) $element['id']]['function']}($request, $response, [$element]);
|
||||
}
|
||||
|
||||
// @todo: currently all children are executed one after another, maybe consider parallel execution
|
||||
|
|
|
|||
|
|
@ -43,6 +43,14 @@ class WorkflowInstanceAbstract
|
|||
*/
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* Instance data.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $data = '';
|
||||
|
||||
/**
|
||||
* Instance status.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<td>
|
||||
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
||||
<td class="wf-100"><?= $this->getHtml('Name'); ?>
|
||||
<label for="workflowTemplateList-sort-1">
|
||||
<input type="radio" name="workflowTemplateList-sort" id="workflowTemplateList-sort-1">
|
||||
|
|
@ -83,16 +84,6 @@ echo $this->getData('nav')->render(); ?>
|
|||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<tbody>
|
||||
<?php if (!empty($parentPath)) : $url = UriFactory::build('{/base}/workflow/template/list?path=' . $parentPath); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td>
|
||||
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="fa fa-folder-open-o"></i></a>
|
||||
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>">..
|
||||
</a>
|
||||
<td>
|
||||
<td>
|
||||
<td>
|
||||
<?php endif; ?>
|
||||
<?php $count = 0; foreach ($templates as $key => $template) : ++$count;
|
||||
$url = UriFactory::build('{/base}/workflow/template/profile?{?}&id=' . $template->id); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
|
|
@ -101,6 +92,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<td>
|
||||
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml((string) $template->id); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->name); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Creator'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $template->createdBy->id); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$template->createdBy->name1, $template->createdBy->name2, $template->createdBy->name3, $template->createdBy->login ?? ''])); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Updated'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->createdAt->format('Y-m-d')); ?></a>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user