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
* [#179](https://github.com/cleverage/ui-process-bundle/issues/179) `CleverAgeUiProcessExtension::findServices()` loads the service definition files with a glob pattern instead of a `Finder` (same files, as [cleverage/process-bundle#271](https://github.com/cleverage/process-bundle/issues/271)). Add tests.
* [#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.
Expand Down
10 changes: 2 additions & 8 deletions src/DependencyInjection/CleverAgeUiProcessExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Notifier\NotifierInterface;

final class CleverAgeUiProcessExtension extends Extension implements PrependExtensionInterface
Expand Down Expand Up @@ -255,16 +254,11 @@ private function configureSecurity(ContainerBuilder $container): void
}

/**
* Recursively import config files into container.
* Import the service definition files of a directory into the container.
*/
protected function findServices(ContainerBuilder $container, string $path, string $extension = 'yaml'): void
{
$finder = new Finder();
$finder->in($path)
->name('*.'.$extension)->files();
$loader = new YamlFileLoader($container, new FileLocator($path));
foreach ($finder as $file) {
$loader->load($file->getFilename());
}
$loader->import('*.'.$extension, 'glob');
}
}
34 changes: 34 additions & 0 deletions tests/DependencyInjection/CleverAgeUiProcessExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,46 @@
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\Yaml\Yaml;

#[CoversClass(CleverAgeUiProcessExtension::class)]
#[UsesClass(Configuration::class)]
#[UsesClass(NotificationTrigger::class)]
class CleverAgeUiProcessExtensionTest extends TestCase
{
public function testEveryServiceDefinitionFileIsLoaded(): void
{
$container = $this->createContainer('prod');
(new CleverAgeUiProcessExtension())->load([], $container);

$files = glob(\dirname(__DIR__, 2).'/config/services/*.yaml');
self::assertIsArray($files);
self::assertNotEmpty($files);
foreach ($files as $file) {
$config = Yaml::parseFile($file, Yaml::PARSE_CUSTOM_TAGS);
self::assertIsArray($config);
if (!isset($config['services'])) {
continue;
}
self::assertIsArray($config['services']);
foreach (array_keys($config['services']) as $id) {
if ('_defaults' === $id) {
continue;
}
if (str_ends_with((string) $id, '\\')) {
// Resource: at least one service registered under the namespace prefix
$registered = array_filter(
array_keys($container->getDefinitions()),
static fn (string $definitionId): bool => str_starts_with($definitionId, (string) $id)
);
self::assertNotEmpty($registered, \sprintf('No service registered for the "%s" resource of %s', $id, basename($file)));
continue;
}
self::assertTrue($container->has((string) $id), \sprintf('Service "%s" of %s is not registered', $id, basename($file)));
}
}
}

public function testLoadWithDefaultConfiguration(): void
{
$container = $this->createContainer('prod');
Expand Down
Loading