Skip to content

Commit 938dda0

Browse files
#40 - upgrade to EA 5
1 parent 52829c9 commit 938dda0

7 files changed

Lines changed: 16 additions & 16 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"doctrine/doctrine-migrations-bundle": "^3.7 || ^4",
4747
"doctrine/orm": "^2.20 || ^3.5",
4848
"dragonmantank/cron-expression": "^3.6",
49-
"easycorp/easyadmin-bundle": "^4.27",
49+
"easycorp/easyadmin-bundle": "^5",
5050
"symfony/doctrine-messenger": "^6.4 || ^7.4 || ^8",
5151
"symfony/dotenv": "^6.4 || ^7.4 || ^8",
5252
"symfony/messenger":"^6.4 || ^7.4 || ^8",

src/Admin/Field/ContextField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515

1616
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
1717
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
18+
use Symfony\Contracts\Translation\TranslatableInterface;
1819

1920
class ContextField implements FieldInterface
2021
{
2122
use FieldTrait;
2223

23-
public static function new(string $propertyName, ?string $label = null): self
24+
public static function new(string $propertyName, TranslatableInterface|string|bool|null $label = null): self
2425
{
2526
return (new self())
2627
->setProperty($propertyName)

src/Admin/Field/EnumField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515

1616
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
1717
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
18+
use Symfony\Contracts\Translation\TranslatableInterface;
1819

1920
class EnumField implements FieldInterface
2021
{
2122
use FieldTrait;
2223

23-
public static function new(string $propertyName, ?string $label = null): self
24+
public static function new(string $propertyName, TranslatableInterface|string|bool|null $label = null): self
2425
{
2526
return (new self())
2627
->setProperty($propertyName)

src/Admin/Field/LogLevelField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515

1616
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
1717
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
18+
use Symfony\Contracts\Translation\TranslatableInterface;
1819

1920
class LogLevelField implements FieldInterface
2021
{
2122
use FieldTrait;
2223

23-
public static function new(string $propertyName, ?string $label = null): self
24+
public static function new(string $propertyName, TranslatableInterface|string|bool|null $label = null): self
2425
{
2526
return (new self())
2627
->setProperty($propertyName)

src/Controller/Admin/ProcessDashboardController.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,19 @@
1313

1414
namespace CleverAge\UiProcessBundle\Controller\Admin;
1515

16-
use CleverAge\UiProcessBundle\Entity\LogRecord;
17-
use CleverAge\UiProcessBundle\Entity\ProcessExecution;
18-
use CleverAge\UiProcessBundle\Entity\ProcessSchedule;
1916
use CleverAge\UiProcessBundle\Entity\User;
17+
use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminDashboard;
2018
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
2119
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
2220
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
2321
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
2422
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
2523
use Symfony\Component\HttpFoundation\Response;
26-
use Symfony\Component\Routing\Attribute\Route;
2724
use Symfony\Component\Security\Http\Attribute\IsGranted;
2825
use Symfony\Component\Translation\LocaleSwitcher;
2926

3027
#[IsGranted('ROLE_USER')]
28+
#[AdminDashboard(routePath: '/process', routeName: 'process')]
3129
class ProcessDashboardController extends AbstractDashboardController
3230
{
3331
public function __construct(
@@ -36,7 +34,6 @@ public function __construct(
3634
) {
3735
}
3836

39-
#[Route('/process', name: 'process')]
4037
public function index(): Response
4138
{
4239
$adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
@@ -57,15 +54,15 @@ public function configureMenuItems(): iterable
5754
yield MenuItem::subMenu('Process', 'fas fa-gear')->setSubItems(
5855
[
5956
MenuItem::linkToRoute('Process list', 'fas fa-list', 'process_list'),
60-
MenuItem::linkToCrud('Executions', 'fas fa-rocket', ProcessExecution::class),
61-
MenuItem::linkToCrud('Logs', 'fas fa-pen', LogRecord::class),
62-
MenuItem::linkToCrud('Scheduler', 'fas fa-solid fa-clock', ProcessSchedule::class),
57+
MenuItem::linkTo(ProcessExecutionCrudController::class, 'Executions', 'fas fa-rocket'),
58+
MenuItem::linkTo(LogRecordCrudController::class, 'Logs', 'fas fa-pen'),
59+
MenuItem::linkTo(ProcessScheduleCrudController::class, 'Scheduler', 'fas fa-solid fa-clock'),
6360
]
6461
);
6562
if ($this->isGranted('ROLE_ADMIN')) {
6663
yield MenuItem::subMenu('Users', 'fas fa-user')->setSubItems(
6764
[
68-
MenuItem::linkToCrud('User List', 'fas fa-user', User::class),
65+
MenuItem::linkTo(UserCrudController::class, 'User List', 'fas fa-user'),
6966
]
7067
);
7168
}

src/Controller/Admin/ProcessExecutionCrudController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function showLogs(): RedirectResponse
135135
public function downloadLogFile(): Response
136136
{
137137
/** @var ProcessExecution $processExecution */
138-
$processExecution = $this->getContext()->getEntity()->getInstance();
138+
$processExecution = $this->getContext()?->getEntity()->getInstance();
139139
$filepath = $this->getLogFilePath($processExecution);
140140
$basename = basename($filepath);
141141
$content = file_get_contents($filepath);

src/Controller/Admin/UserCrudController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public function generateToken(): Response
108108
{
109109
$adminContext = $this->getContext();
110110
/** @var User $user */
111-
$user = $adminContext->getEntity()->getInstance();
111+
$user = $adminContext?->getEntity()->getInstance();
112112
$token = md5(uniqid(date('YmdHis')));
113113
$user->setToken((new Pbkdf2PasswordHasher())->hash($token));
114114
$this->persistEntity(
115-
$this->container->get('doctrine')->getManagerForClass($adminContext->getEntity()->getFqcn()),
115+
$this->container->get('doctrine')->getManagerForClass($adminContext?->getEntity()->getFqcn()),
116116
$user
117117
);
118118
$this->addFlash('success', 'New token generated '.$token.' (keep it in secured area. This token will never be displayed anymore)');

0 commit comments

Comments
 (0)