Skip to content

Commit 65b2003

Browse files
#13 ability to add modal confirmation or nothing instead of launch from of process run ui.
PhpStan
1 parent b1433dc commit 65b2003

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/Controller/Admin/Process/LaunchAction.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Symfony\Component\Routing\Attribute\Route;
3131
use Symfony\Component\Security\Http\Attribute\IsGranted;
3232
use Symfony\Component\Uid\Uuid;
33+
use Symfony\Component\Validator\Exception\MissingOptionsException;
3334

3435
#[Route(
3536
'/process/launch',
@@ -55,6 +56,9 @@ public function __invoke(
5556
throw new MissingProcessException();
5657
}
5758
$uiOptions = $processConfigurationsManager->getUiOptions($processCode);
59+
if (null === $uiOptions) {
60+
throw new \InvalidArgumentException("Missing UI Options");
61+
}
5862
if (false === $uiOptions['input_context_launcher_form']) {
5963
$this->dispatch($processCode);
6064
$this->addFlash(
@@ -68,12 +72,12 @@ public function __invoke(
6872
LaunchType::class,
6973
null,
7074
[
71-
'constraints' => $uiOptions['constraints'] ?? [],
75+
'constraints' => $uiOptions['constraints'],
7276
'process_code' => $processCode,
7377
]
7478
);
7579
if (false === $form->isSubmitted()) {
76-
$default = $uiOptions['default'] ?? [];
80+
$default = $uiOptions['default'];
7781
if (false === $form->get('input')->getConfig()->getType()->getInnerType() instanceof TextType
7882
&& isset($default['input'])
7983
) {
@@ -111,6 +115,9 @@ public function __invoke(
111115
);
112116
}
113117

118+
/**
119+
* @param mixed[] $context
120+
*/
114121
protected function dispatch(string $processCode, mixed $input = null, array $context = []): void
115122
{
116123
$message = new ProcessExecuteMessage(

src/Manager/ProcessConfigurationsManager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* @phpstan-type UiOptions array{
2525
* 'source': ?string,
2626
* 'target': ?string,
27+
* 'input_context_launcher_form': bool,
28+
* 'run_confirmation_modal': bool,
2729
* 'entrypoint_type': string,
2830
* 'constraints': Constraint[],
2931
* 'run': 'null|bool',

src/Twig/Runtime/ProcessExtensionRuntime.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
use CleverAge\UiProcessBundle\Manager\ProcessConfigurationsManager;
1515
use Twig\Extension\RuntimeExtensionInterface;
1616

17+
/**
18+
* @phpstan-import-type UiOptions from ProcessConfigurationsManager
19+
*/
1720
class ProcessExtensionRuntime implements RuntimeExtensionInterface
1821
{
1922
public function __construct(protected ProcessConfigurationsManager $processConfigurationsManager)
2023
{
2124
}
2225

26+
/**
27+
* @return UiOptions|array{}
28+
*/
2329
public function getUiOptions(string $code): array
2430
{
2531
return $this->processConfigurationsManager->getUiOptions($code) ?? [];

0 commit comments

Comments
 (0)