Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Latest
------

## Changes
* [#172](https://github.com/cleverage/ui-process-bundle/issues/172) Prefix the route names of the bundle with `cleverage_ui_process_`, as required by the Symfony best practices for bundles: `cleverage_ui_process_login`, `cleverage_ui_process_logout`, `cleverage_ui_process_list`, `cleverage_ui_process_launch`, `cleverage_ui_process_http_execute`, and the dashboard `cleverage_ui_process`, so that the routes generated by EasyAdmin for the CRUD pages are `cleverage_ui_process_<crud>_<action>`. The former names (`process`, `process_<crud>_<action>`, `process_login`, `process_logout`, `process_list`, `process_launch`, `http_process_execute`) are deprecated route aliases (new `config/routes/deprecated_aliases.yaml`, loaded by the documented import, and internal `DeprecatedEasyAdminRouteAliasLoader` for the routes generated by EasyAdmin), removed in 4.0; `?routeName=<former name>` URLs keep working. Document that `easyadmin.routes` generates the routes of every dashboard. Update documentation and UPGRADE.md, add tests.
* [#166](https://github.com/cleverage/ui-process-bundle/issues/166) Doctrine ORM 2: the entities have readonly properties (since v3.2), which the legacy proxies of ORM 2 cannot handle (`Cannot unset readonly property ... from scope Proxies\__CG__\...` when an entity proxy is loaded). The container compilation now fails with an explicit message when ORM 2 is used without `doctrine.orm.enable_lazy_ghost_objects: true` (new internal `CheckDoctrineLazyGhostObjectsPass`); nothing changes with ORM 3. Update documentation, add tests.
* [#164](https://github.com/cleverage/ui-process-bundle/issues/164) Require `symfony/polyfill-php83`, `symfony/polyfill-php84` and `symfony/polyfill-php85`: the functions of PHP 8.3 to 8.5 (`json_validate()`, `array_find()`, `array_first()`...) can be used while supporting PHP 8.2 (see `CONTRIBUTING.md`). Rector is configured for PHP 8.2 (was 8.5, which allowed it to introduce PHP 8.3+ functions without polyfill) with the `PHP_POLYFILLS` set (`withPhpSets()` without argument), it does not change the code. `array_last()` replaces `end()` in a test. Tests: lazy ghost proxies with Doctrine ORM 2 (now installed by the lowest dependencies job), as configured by the Symfony recipe: the legacy proxies cannot unset the readonly properties of the entities.
* [#158](https://github.com/cleverage/ui-process-bundle/issues/158) CI: test the lowest versions allowed by `composer.json` (`--prefer-lowest`, PHP 8.2). Require `symfony/scheduler` ^6.4.44 || ^7.4.17 || ^8.1.5: the `every` expressions validation (`EveryExpressionValidator`) relies on the `PeriodicalTrigger` rejecting the intervals that do not move the run date forward or resolve to zero seconds (older versions loop forever on e.g. "yesterday", and fail with a `TypeError` on an invalid expression). `ProcessExecutionDurationFilter`: the number of seconds is cast to an integer and inlined in the DQL instead of being bound as a parameter (#111): with DBAL 3, the SQLite platform puts the `SECOND` intervals inside a string literal, so the parameter was never bound ("column index out of range" error on SQLite with DBAL 3).
Expand Down
21 changes: 21 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
Upgrade Guide
=============

## v3.3

### Route names

The routes of the bundle are prefixed with `cleverage_ui_process_`. The former names are deprecated aliases, removed in
4.0: update the references in your application (`path()` / `url()`, `redirectToRoute()`, security configuration when
`security.configure_firewall` is `false`...).

| Before (deprecated) | After |
|---------------------------|----------------------------------------|
| `process` | `cleverage_ui_process` (dashboard) |
| `process_<crud>_<action>` | `cleverage_ui_process_<crud>_<action>` |
| `process_login` | `cleverage_ui_process_login` |
| `process_logout` | `cleverage_ui_process_logout` |
| `process_list` | `cleverage_ui_process_list` |
| `process_launch` | `cleverage_ui_process_launch` |
| `http_process_execute` | `cleverage_ui_process_http_execute` |

The routes of the CRUD pages are generated by EasyAdmin from the dashboard route name, e.g.
`process_process_execution_index` is now `cleverage_ui_process_process_execution_index`.

## v3.0

### Import routes
Expand Down
41 changes: 41 additions & 0 deletions config/routes/deprecated_aliases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Former names of the routes of the bundle, deprecated since 3.3 (removed in 4.0): use the cleverage_ui_process_* names

process_login:
alias: cleverage_ui_process_login
deprecated:
package: 'cleverage/ui-process-bundle'
version: '3.3'
message: 'The "%alias_id%" route alias is deprecated, use the "cleverage_ui_process_login" route instead. It will be removed in 4.0.'

process_logout:
alias: cleverage_ui_process_logout
deprecated:
package: 'cleverage/ui-process-bundle'
version: '3.3'
message: 'The "%alias_id%" route alias is deprecated, use the "cleverage_ui_process_logout" route instead. It will be removed in 4.0.'

process_list:
alias: cleverage_ui_process_list
deprecated:
package: 'cleverage/ui-process-bundle'
version: '3.3'
message: 'The "%alias_id%" route alias is deprecated, use the "cleverage_ui_process_list" route instead. It will be removed in 4.0.'

process_launch:
alias: cleverage_ui_process_launch
deprecated:
package: 'cleverage/ui-process-bundle'
version: '3.3'
message: 'The "%alias_id%" route alias is deprecated, use the "cleverage_ui_process_launch" route instead. It will be removed in 4.0.'

http_process_execute:
alias: cleverage_ui_process_http_execute
deprecated:
package: 'cleverage/ui-process-bundle'
version: '3.3'
message: 'The "%alias_id%" route alias is deprecated, use the "cleverage_ui_process_http_execute" route instead. It will be removed in 4.0.'

# Dashboard ("process") and routes generated by EasyAdmin from it ("process_<crud>_<action>")
cleverage_ui_process_deprecated_easyadmin_route_aliases:
resource: .
type: cleverage_ui_process.deprecated_easyadmin_route_aliases
6 changes: 6 additions & 0 deletions config/services/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
cleverage_ui_process.routing.deprecated_easyadmin_route_alias_loader:
class: CleverAge\UiProcessBundle\Routing\DeprecatedEasyAdminRouteAliasLoader
public: false
tags:
- { name: routing.loader }
51 changes: 32 additions & 19 deletions docs/reference/03-users_and_security.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ security:
provider: process_user_provider
custom_authenticator: [cleverage_ui_process.security.http_process_execution_authenticator]
form_login:
login_path: process_login
check_path: process_login
login_path: cleverage_ui_process_login
check_path: cleverage_ui_process_login
logout:
path: process_logout
target: process_login
path: cleverage_ui_process_logout
target: cleverage_ui_process_login
clear_site_data: '*'
```

Expand Down Expand Up @@ -51,10 +51,10 @@ environment variable): the bundle no longer adds any `security` configuration, n
firewall. Configure them in your application, on the firewall and with the provider of your choice. The UI requires:

- a user provider of the `CleverAge\UiProcessBundle\Entity\User` entity, by `email`;
- a firewall covering the UI routes, with a login form on the `process_login` route and the logout on the
`process_logout` route;
- a firewall covering the UI routes, with a login form on the `cleverage_ui_process_login` route and the logout on the
`cleverage_ui_process_logout` route;
- the `cleverage_ui_process.security.http_process_execution_authenticator` authenticator on the firewall covering the
`http_process_execute` route, for the [HTTP API](06-http_api.md).
`cleverage_ui_process_http_execute` route, for the [HTTP API](06-http_api.md).

For instance, with the same behaviour as the bundle configuration on a firewall dedicated to the UI:

Expand All @@ -79,11 +79,11 @@ security:
provider: process_user_provider
custom_authenticator: [cleverage_ui_process.security.http_process_execution_authenticator]
form_login:
login_path: process_login
check_path: process_login
login_path: cleverage_ui_process_login
check_path: cleverage_ui_process_login
logout:
path: process_logout
target: process_login
path: cleverage_ui_process_logout
target: cleverage_ui_process_login
clear_site_data: '*'
main:
# ... your application firewall
Expand Down Expand Up @@ -132,11 +132,24 @@ Routes

Routes are imported with `@CleverAgeUiProcessBundle/config/routes/*.yaml` (see [installation](../index.md#import-routes)).

| Route name | Path | Description |
|------------------------------|---------------------------------|----------------------------------------------------------------------------------------------|
| `process` | `/process` | EasyAdmin dashboard, redirects to the executions list. CRUD pages are sub-routes of it. |
| `process_login` | `/process/login` | Login form. |
| `process_logout` | `/process/logout` | Logout. |
| `process_list` | `/process/list` | List of public processes. |
| `process_launch` | `/process/launch?process=<code>` | Launch a process (confirmation, form or direct, see [launch modes](02-process_ui_options.md#launch-modes)). |
| `http_process_execute` | `/http/process/execute` (POST) | [HTTP API](06-http_api.md). |
| Route name | Former name (deprecated) | Path | Description |
|-------------------------------------|--------------------------|----------------------------------|----------------------------------------------------------------------------------------------|
| `cleverage_ui_process` | `process` | `/process` | EasyAdmin dashboard, redirects to the executions list. CRUD pages are sub-routes of it. |
| `cleverage_ui_process_login` | `process_login` | `/process/login` | Login form. |
| `cleverage_ui_process_logout` | `process_logout` | `/process/logout` | Logout. |
| `cleverage_ui_process_list` | `process_list` | `/process/list` | List of public processes. |
| `cleverage_ui_process_launch` | `process_launch` | `/process/launch?process=<code>` | Launch a process (confirmation, form or direct, see [launch modes](02-process_ui_options.md#launch-modes)). |
| `cleverage_ui_process_http_execute` | `http_process_execute` | `/http/process/execute` (POST) | [HTTP API](06-http_api.md). |

The routes of the CRUD pages are generated by EasyAdmin from the dashboard route name:
`cleverage_ui_process_<crud>_<action>` (e.g. `cleverage_ui_process_process_execution_index`), formerly
`process_<crud>_<action>`.

The former route names are deprecated aliases since 3.3 (`config/routes/deprecated_aliases.yaml`), removed in 4.0:
generating a URL with them, or opening a `?routeName=<former name>` URL of the dashboard, still works and triggers a
deprecation.

The EasyAdmin routes (the dashboard and its CRUD pages) are generated by the `easyadmin.routes` loader imported by
`config/routes/easyadmin.yaml`. This loader generates the routes of **every** dashboard, including the ones of your
application: a `prefix` set on the import of the bundle routes also applies to the dashboards of your application, and
`easyadmin.routes` must not be imported a second time.
4 changes: 2 additions & 2 deletions docs/reference/06-http_api.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
HTTP API
========

A process can be launched from another application with an HTTP `POST` request on the `http_process_execute` route.
A process can be launched from another application with an HTTP `POST` request on the `cleverage_ui_process_http_execute` route.

Endpoint
--------

* **Route**: `http_process_execute`
* **Route**: `cleverage_ui_process_http_execute`
* **Path**: `/http/process/execute`
* **Method**: `POST`
* **Authentication**: `Authorization: Bearer <token>` header
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/Admin/Process/LaunchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#[Route(
'/process/launch',
name: 'process_launch',
name: 'cleverage_ui_process_launch',
requirements: ['process' => '\w+'],
methods: ['POST', 'GET']
)]
Expand All @@ -54,7 +54,7 @@ public function __invoke(
): Response {
// Accessed directly, not through the dashboard: the template needs the EasyAdmin context
if (!$this->adminContextProvider->getContext() instanceof AdminContextInterface) {
return $this->redirectToRoute('process', ['routeName' => 'process_launch'] + ($this->requestStack->getMainRequest()?->query->all() ?? []));
return $this->redirectToRoute('cleverage_ui_process', ['routeName' => 'cleverage_ui_process_launch'] + ($this->requestStack->getMainRequest()?->query->all() ?? []));
}
$processCode = (string) $this->requestStack->getMainRequest()?->query->get('process');
if ('' === $processCode) {
Expand All @@ -71,7 +71,7 @@ public function __invoke(
'Process has been added to queue. It will start as soon as possible'
);

return $this->redirectToRoute('process', ['routeName' => 'process_list']);
return $this->redirectToRoute('cleverage_ui_process', ['routeName' => 'cleverage_ui_process_list']);
}
$form = $this->createForm(
LaunchType::class,
Expand Down Expand Up @@ -108,7 +108,7 @@ public function __invoke(
'Process has been added to queue. It will start as soon as possible'
);

return $this->redirectToRoute('process', ['routeName' => 'process_list']);
return $this->redirectToRoute('cleverage_ui_process', ['routeName' => 'cleverage_ui_process_list']);
}
$this->adminContextProvider->getContext()->getAssets()->addJsAsset(Asset::fromEasyAdminAssetPackage('field-collection.js')->getAsDto());

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/Process/ListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[Route('/process/list', name: 'process_list')]
#[Route('/process/list', name: 'cleverage_ui_process_list')]
#[IsGranted('ROLE_USER')]
class ListAction extends AbstractController
{
Expand All @@ -37,7 +37,7 @@ public function __invoke(): Response
{
// Accessed directly, not through the dashboard: the template needs the EasyAdmin context
if (!$this->adminContextProvider->getContext() instanceof AdminContextInterface) {
return $this->redirectToRoute('process', ['routeName' => 'process_list']);
return $this->redirectToRoute('cleverage_ui_process', ['routeName' => 'cleverage_ui_process_list']);
}

return $this->render(
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/ProcessDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use Symfony\Component\Translation\LocaleSwitcher;

#[IsGranted('ROLE_USER')]
#[AdminDashboard(routePath: '/process', routeName: 'process')]
#[AdminDashboard(routePath: '/process', routeName: 'cleverage_ui_process')]
class ProcessDashboardController extends AbstractDashboardController
{
public function __construct(
Expand Down Expand Up @@ -60,7 +60,7 @@ public function configureMenuItems(): iterable
yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
yield MenuItem::subMenu('Process', 'fas fa-gear')->setSubItems(
[
MenuItem::linkToRoute('Process list', 'fas fa-list', 'process_list'),
MenuItem::linkToRoute('Process list', 'fas fa-list', 'cleverage_ui_process_list'),
MenuItem::linkTo(ProcessExecutionCrudController::class, 'Executions', 'fas fa-rocket'),
MenuItem::linkTo(LogRecordCrudController::class, 'Logs', 'fas fa-pen'),
MenuItem::linkTo(ProcessScheduleCrudController::class, 'Scheduler', 'fas fa-solid fa-clock'),
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/Security/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

class LoginController extends AbstractController
{
#[Route('/process/login', name: 'process_login')]
#[Route('/process/login', name: 'cleverage_ui_process_login')]
public function __invoke(AuthenticationUtils $authenticationUtils): Response
{
return $this->render(
'@CleverAgeUiProcess/admin/login.html.twig',
[
'page_title' => 'Login',
'target_path' => $this->generateUrl('process'),
'target_path' => $this->generateUrl('cleverage_ui_process'),
'error' => $authenticationUtils->getLastAuthenticationError(),
'last_username' => $authenticationUtils->getLastUsername(),
]
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/Security/LogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public function __construct(private readonly Security $security)
{
}

#[Route('/process/logout', name: 'process_logout')]
#[Route('/process/logout', name: 'cleverage_ui_process_logout')]
public function __invoke(): Response
{
$this->security->logout();

return $this->redirectToRoute('process_login');
return $this->redirectToRoute('cleverage_ui_process_login');
}
}
2 changes: 1 addition & 1 deletion src/Controller/ProcessExecuteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use Symfony\Component\Validator\Validator\ValidatorInterface;

#[IsGranted('ROLE_USER')]
#[Route(path: '/http/process/execute', name: 'http_process_execute', methods: ['POST'])]
#[Route(path: '/http/process/execute', name: 'cleverage_ui_process_http_execute', methods: ['POST'])]
class ProcessExecuteController extends AbstractController
{
public function __construct(
Expand Down
8 changes: 4 additions & 4 deletions src/DependencyInjection/CleverAgeUiProcessExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ private function configureSecurity(ContainerBuilder $container): void
'provider' => 'process_user_provider',
'custom_authenticator' => ['cleverage_ui_process.security.http_process_execution_authenticator'],
'form_login' => [
'login_path' => 'process_login',
'check_path' => 'process_login',
'login_path' => 'cleverage_ui_process_login',
'check_path' => 'cleverage_ui_process_login',
],
'logout' => [
'path' => 'process_logout',
'target' => 'process_login',
'path' => 'cleverage_ui_process_logout',
'target' => 'cleverage_ui_process_login',
'clear_site_data' => '*',
],
],
Expand Down
Loading
Loading