Skip to content

Commit a3303c2

Browse files
Apply quality rules
1 parent 4bdacb2 commit a3303c2

File tree

58 files changed

+624
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+624
-190
lines changed

src/Admin/Field/EnumField.php

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Admin\Field;
615

716
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;

src/Admin/Field/LogLevelField.php

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Admin\Field;
615

716
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;

src/Admin/Filter/LogProcessFilter.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Admin\Filter;
615

716
use Doctrine\ORM\QueryBuilder;
@@ -18,17 +27,16 @@ class LogProcessFilter implements FilterInterface
1827
use FilterTrait;
1928

2029
public static function new(
21-
$label,
30+
mixed $label,
2231
array $choices,
23-
null|string|int $executionId = null,
24-
): self
25-
{
32+
string|int|null $executionId = null,
33+
): self {
2634
if (is_numeric($executionId)) {
2735
$choices = [$executionId => $executionId];
2836
}
2937

3038
return (new self())
31-
->setFilterFqcn(__CLASS__)
39+
->setFilterFqcn(self::class)
3240
->setProperty('process')
3341
->setLabel($label)
3442
->setFormType(ChoiceFilterType::class)

src/Command/UserCreateCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class UserCreateCommand extends Command
3838
public function __construct(
3939
private readonly ValidatorInterface $validator,
4040
private readonly UserPasswordHasherInterface $passwordEncoder,
41-
private readonly EntityManagerInterface $em
41+
private readonly EntityManagerInterface $em,
4242
) {
4343
parent::__construct();
4444
}

src/Controller/Admin/LogRecordCrudController.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Controller\Admin;
615

716
use CleverAge\ProcessBundle\Configuration\ProcessConfiguration;
@@ -28,7 +37,7 @@ class LogRecordCrudController extends AbstractCrudController
2837
{
2938
public function __construct(
3039
private readonly ProcessConfigurationsManager $processConfigurationsManager,
31-
private readonly RequestStack $request
40+
private readonly RequestStack $request,
3241
) {
3342
}
3443

@@ -74,7 +83,7 @@ public function configureActions(Actions $actions): Actions
7483

7584
public function configureFilters(Filters $filters): Filters
7685
{
77-
$id = $this->request->getMainRequest()->query->all('filters')['process']['value'] ?? null;
86+
$id = $this->request->getMainRequest()?->query->all('filters')['process']['value'] ?? null;
7887
$processList = $this->processConfigurationsManager->getPublicProcesses();
7988
$processList = array_map(fn (ProcessConfiguration $cfg) => $cfg->getCode(), $processList);
8089

src/Controller/Admin/Process/LaunchAction.php

+14-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Controller\Admin\Process;
615

716
use CleverAge\ProcessBundle\Configuration\ProcessConfiguration;
@@ -20,11 +29,10 @@
2029
use Symfony\Component\HttpFoundation\Response;
2130
use Symfony\Component\HttpKernel\Attribute\ValueResolver;
2231
use Symfony\Component\Messenger\MessageBusInterface;
23-
use Symfony\Component\Routing\Annotation\Route;
2432
use Symfony\Component\Security\Http\Attribute\IsGranted;
2533
use Symfony\Component\Uid\Uuid;
2634

27-
#[Route(
35+
#[\Symfony\Component\Routing\Attribute\Route(
2836
'/process/launch',
2937
name: 'process_launch',
3038
requirements: ['process' => '\w+'],
@@ -41,17 +49,17 @@ public function __invoke(
4149
ProcessConfigurationsManager $configurationsManager,
4250
AdminContext $context,
4351
): Response {
44-
$uiOptions = $configurationsManager->getUiOptions($requestStack->getMainRequest()->get('process'));
52+
$uiOptions = $configurationsManager->getUiOptions($requestStack->getMainRequest()?->get('process') ?? '');
4553
$form = $this->createForm(
4654
LaunchType::class,
4755
null,
4856
[
49-
'constraints' => $uiOptions['constraints'],
57+
'constraints' => $uiOptions['constraints'] ?? [],
5058
'process_code' => $requestStack->getMainRequest()?->get('process'),
5159
]
5260
);
5361
if (false === $form->isSubmitted()) {
54-
$default = $uiOptions['default'];
62+
$default = $uiOptions['default'] ?? [];
5563
if (false === $form->get('input')->getConfig()->getType()->getInnerType() instanceof TextType
5664
&& isset($default['input'])
5765
) {
@@ -61,10 +69,9 @@ public function __invoke(
6169
}
6270
$form->handleRequest($requestStack->getMainRequest());
6371
if ($form->isSubmitted() && $form->isValid()) {
64-
/** @var mixed|UploadedFile $file */
6572
$input = $form->get('input')->getData();
6673
if ($input instanceof UploadedFile) {
67-
$filename = sprintf('%s/%s.%s', $uploadDirectory, Uuid::v4(), $input->getClientOriginalExtension());
74+
$filename = \sprintf('%s/%s.%s', $uploadDirectory, Uuid::v4(), $input->getClientOriginalExtension());
6875
(new Filesystem())->dumpFile($filename, $input->getContent());
6976
$input = $filename;
7077
}

src/Controller/Admin/Process/ListAction.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Controller\Admin\Process;
615

716
use CleverAge\ProcessUiBundle\Manager\ProcessConfigurationsManager;
817
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
918
use Symfony\Component\HttpFoundation\Response;
10-
use Symfony\Component\Routing\Annotation\Route;
1119
use Symfony\Component\Security\Http\Attribute\IsGranted;
1220

13-
#[Route('/process/list', name: 'process_list')]
21+
#[\Symfony\Component\Routing\Attribute\Route('/process/list', name: 'process_list')]
1422
#[IsGranted('ROLE_USER')]
1523
class ListAction extends AbstractController
1624
{

src/Controller/Admin/Process/UploadAndExecuteAction.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Controller\Admin\Process;
615

716
use CleverAge\ProcessBundle\Configuration\ProcessConfiguration;
@@ -15,11 +24,10 @@
1524
use Symfony\Component\HttpFoundation\Response;
1625
use Symfony\Component\HttpKernel\Attribute\ValueResolver;
1726
use Symfony\Component\Messenger\MessageBusInterface;
18-
use Symfony\Component\Routing\Annotation\Route;
1927
use Symfony\Component\Security\Http\Attribute\IsGranted;
2028
use Symfony\Component\Uid\Uuid;
2129

22-
#[Route(
30+
#[\Symfony\Component\Routing\Attribute\Route(
2331
'/process/upload-and-execute',
2432
name: 'process_upload_and_execute',
2533
requirements: ['process' => '\w+'],
@@ -32,9 +40,9 @@ public function __invoke(
3240
RequestStack $requestStack,
3341
MessageBusInterface $messageBus,
3442
#[Autowire(param: 'upload_directory')] string $uploadDirectory,
35-
#[ValueResolver('process')] ProcessConfiguration $processConfiguration
43+
#[ValueResolver('process')] ProcessConfiguration $processConfiguration,
3644
): Response {
37-
if (null === $processConfiguration->getEntryPoint()) {
45+
if (!$processConfiguration->getEntryPoint() instanceof \CleverAge\ProcessBundle\Configuration\TaskConfiguration) {
3846
throw new \RuntimeException('You must set an entry_point.');
3947
}
4048
$form = $this->createForm(
@@ -46,7 +54,7 @@ public function __invoke(
4654
if ($form->isSubmitted() && $form->isValid()) {
4755
/** @var UploadedFile $file */
4856
$file = $form->getData();
49-
$savedFilepath = sprintf('%s/%s.%s', $uploadDirectory, Uuid::v4(), $file->getClientOriginalExtension());
57+
$savedFilepath = \sprintf('%s/%s.%s', $uploadDirectory, Uuid::v4(), $file->getClientOriginalExtension());
5058
(new Filesystem())->dumpFile($savedFilepath, $file->getContent());
5159
$messageBus->dispatch(
5260
new ProcessExecuteMessage(

src/Controller/Admin/ProcessDashboardController.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Controller\Admin;
615

716
use CleverAge\ProcessUiBundle\Entity\LogRecord;
@@ -14,7 +23,6 @@
1423
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
1524
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
1625
use Symfony\Component\HttpFoundation\Response;
17-
use Symfony\Component\Routing\Annotation\Route;
1826
use Symfony\Component\Security\Http\Attribute\IsGranted;
1927
use Symfony\Component\Translation\LocaleSwitcher;
2028

@@ -23,11 +31,11 @@ class ProcessDashboardController extends AbstractDashboardController
2331
{
2432
public function __construct(
2533
private readonly LocaleSwitcher $localeSwitcher,
26-
private readonly string $logoPath = ''
34+
private readonly string $logoPath = '',
2735
) {
2836
}
2937

30-
#[Route('/process', name: 'process')]
38+
#[\Symfony\Component\Routing\Attribute\Route('/process', name: 'process')]
3139
public function index(): Response
3240
{
3341
$adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
@@ -63,7 +71,7 @@ public function configureMenuItems(): iterable
6371

6472
public function configureCrud(): Crud
6573
{
66-
/** @var User $user */
74+
/** @var ?User $user */
6775
$user = $this->getUser();
6876
if (null !== $user?->getLocale()) {
6977
$this->localeSwitcher->setLocale($user->getLocale());

src/Controller/Admin/ProcessExecutionCrudController.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the CleverAge/UiProcessBundle package.
7+
*
8+
* Copyright (c) Clever-Age
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace CleverAge\ProcessUiBundle\Controller\Admin;
615

716
use CleverAge\ProcessUiBundle\Admin\Field\EnumField;
@@ -96,7 +105,7 @@ public function showLogs(AdminContext $adminContext): RedirectResponse
96105
[
97106
'process' => [
98107
'comparison' => '=',
99-
'value' => $this->getContext()->getEntity()->getInstance()->getId(),
108+
'value' => $this->getContext()?->getEntity()->getInstance()->getId(),
100109
],
101110
]
102111
)
@@ -111,7 +120,7 @@ public function downloadLogFile(
111120
): Response {
112121
/** @var ProcessExecution $processExecution */
113122
$processExecution = $context->getEntity()->getInstance();
114-
$filepath = $directory.DIRECTORY_SEPARATOR.$processExecution->code.DIRECTORY_SEPARATOR
123+
$filepath = $directory.\DIRECTORY_SEPARATOR.$processExecution->code.\DIRECTORY_SEPARATOR
115124
.$processExecution->logFilename;
116125
$basename = basename($filepath);
117126
$content = file_get_contents($filepath);

0 commit comments

Comments
 (0)