From 8018e15c35e3bd8e96c853e586ae39c33d195d14 Mon Sep 17 00:00:00 2001 From: Dragos Protung Date: Fri, 6 Nov 2026 09:21:40 +0100 Subject: [PATCH] Allow EasyAdmin 5.8 & 5.9 --- composer.json | 16 +++++++------- config/mago-analyze-baseline.toml | 22 +++++++++++++++++-- src/ProtungEasyAdminPlusBundle.php | 19 +++++++++++----- ...tOutput-no-data-since-easyadmin-5.8-1.html | 1 + .../Views/Crud/Field/JsonFieldTest.php | 10 ++++++++- 5 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 tests/Resources/Views/Crud/Field/Expected/testOutput-no-data-since-easyadmin-5.8-1.html diff --git a/composer.json b/composer.json index 86b31d5..fd92739 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "require": { "php": "~8.4.0 || ~8.5.0", "doctrine/orm": "^2.20.9 || ^3.5.0", - "easycorp/easyadmin-bundle": "~4.29.16 || ~5.6.1 || ~5.7.0", + "easycorp/easyadmin-bundle": "~4.29.16 || ~5.6.1 || ~5.7.0 || ~5.8.0 || ~5.9.0", "php-standard-library/php-standard-library": "^3.3.0 || ^4.0.0 || ^5.0.0 || ^6.0.0", "symfony/config": "^6.4 || ^7.4 || ^8.0", "symfony/dependency-injection": "^6.4 || ^7.4 || ^8.0", @@ -52,16 +52,16 @@ "twig/twig": "^3.27.0" }, "require-dev": { - "carthage-software/mago": "^1.57.0", + "carthage-software/mago": "^1.59.0", "doctrine/coding-standard": "^14.0.0", - "ergebnis/composer-normalize": "^2.54.0", + "ergebnis/composer-normalize": "^2.56.0", "php-standard-library/phpstan-extension": "^2.1.0", - "phpstan/phpstan": "^2.2.16", + "phpstan/phpstan": "^2.3.5", "phpstan/phpstan-deprecation-rules": "^2.0.5", - "phpstan/phpstan-phpunit": "^2.0.19", - "phpstan/phpstan-strict-rules": "^2.0.12", - "phpstan/phpstan-symfony": "^2.0.20", - "phpunit/phpunit": "^13.1.14", + "phpstan/phpstan-phpunit": "^2.1.1", + "phpstan/phpstan-strict-rules": "^2.1.1", + "phpstan/phpstan-symfony": "^2.1.1", + "phpunit/phpunit": "^13.4.6", "roave/security-advisories": "dev-master", "speicher210/functional-test-bundle": "^2.0.0", "symfony/error-handler": "^6.4.44 || ^7.4.17 || ^8.1.5", diff --git a/config/mago-analyze-baseline.toml b/config/mago-analyze-baseline.toml index 1562205..2bee332 100644 --- a/config/mago-analyze-baseline.toml +++ b/config/mago-analyze-baseline.toml @@ -75,8 +75,26 @@ count = 1 [[issues]] file = 'src/Controller/BaseCrudDtoController.php' code = 'mixed-method-access' -message = 'Attempting to access a method on a non-object type (`mixed`).' -count = 14 +message = 'Attempting to call method `dispatch()` on a non-object type (`mixed`).' +count = 8 + +[[issues]] +file = 'src/Controller/BaseCrudDtoController.php' +code = 'mixed-method-access' +message = 'Attempting to call method `getManagerForClass()` on a non-object type (`mixed`).' +count = 2 + +[[issues]] +file = 'src/Controller/BaseCrudDtoController.php' +code = 'mixed-method-access' +message = 'Attempting to call method `processEntityActions()` on a non-object type (`mixed`).' +count = 2 + +[[issues]] +file = 'src/Controller/BaseCrudDtoController.php' +code = 'mixed-method-access' +message = 'Attempting to call method `processFields()` on a non-object type (`mixed`).' +count = 2 [[issues]] file = 'src/Controller/BaseCrudDtoController.php' diff --git a/src/ProtungEasyAdminPlusBundle.php b/src/ProtungEasyAdminPlusBundle.php index 028224e..c2858d2 100644 --- a/src/ProtungEasyAdminPlusBundle.php +++ b/src/ProtungEasyAdminPlusBundle.php @@ -7,7 +7,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemMatcherInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityPaginatorInterface; -use EasyCorp\Bundle\EasyAdminBundle\DependencyInjection\EasyAdminExtension; use EasyCorp\Bundle\EasyAdminBundle\Menu\MenuItemMatcher; use Override; use Protung\EasyAdminPlusBundle\Field\Configurator\CallbackConfigurableConfigurator; @@ -23,6 +22,14 @@ final class ProtungEasyAdminPlusBundle extends AbstractBundle { + /** + * EasyAdmin's own constants can't be used in every supported version: the ones of EasyAdminExtension are + * deprecated since EasyAdmin 5.7.1, and the ones of EasyAdminBundle that replace them only exist since 5.8. + */ + private const string TAG_FIELD_CONFIGURATOR = 'ea.field_configurator'; + + private const string TAG_FILTER_CONFIGURATOR = 'ea.filter_configurator'; + /** * @param array $config */ @@ -32,7 +39,7 @@ public function loadExtension(array $config, ContainerConfigurator $configurator $services = $configurator->services(); $services->defaults()->private()->autowire()->autoconfigure(); - $services->instanceof(FieldConfiguratorInterface::class)->tag(EasyAdminExtension::TAG_FIELD_CONFIGURATOR); + $services->instanceof(FieldConfiguratorInterface::class)->tag(self::TAG_FIELD_CONFIGURATOR); $services->instanceof(FormTypeInterface::class)->tag('form.type'); $services->alias(MenuItemMatcherInterface::class, MenuItemMatcher::class); @@ -44,7 +51,7 @@ public function loadExtension(array $config, ContainerConfigurator $configurator ->autowire() ->autoconfigure() ->private() - ->tag(EasyAdminExtension::TAG_FILTER_CONFIGURATOR, ['priority' => -1]); // must be after \EasyCorp\Bundle\EasyAdminBundle\Filter\Configurator\EntityConfigurator + ->tag(self::TAG_FILTER_CONFIGURATOR, ['priority' => -1]); // must be after \EasyCorp\Bundle\EasyAdminBundle\Filter\Configurator\EntityConfigurator $services->set(EntityPaginator::class) ->decorate(EntityPaginatorInterface::class) @@ -61,18 +68,18 @@ public function loadExtension(array $config, ContainerConfigurator $configurator ->autowire() ->autoconfigure() ->private() - ->tag(EasyAdminExtension::TAG_FIELD_CONFIGURATOR, ['priority' => 10_000]); // must be before \EasyCorp\Bundle\EasyAdminBundle\Field\Configurator\CommonPostConfigurator + ->tag(self::TAG_FIELD_CONFIGURATOR, ['priority' => 10_000]); // must be before \EasyCorp\Bundle\EasyAdminBundle\Field\Configurator\CommonPostConfigurator $services->set(CallbackConfigurableConfigurator::class) ->autowire() ->autoconfigure() ->private() - ->tag(EasyAdminExtension::TAG_FIELD_CONFIGURATOR, ['priority' => 1]); // by design, we want this to kick in before any of the other field configurators with default priority + ->tag(self::TAG_FIELD_CONFIGURATOR, ['priority' => 1]); // by design, we want this to kick in before any of the other field configurators with default priority $services->set(CallbackConfigurableConfiguratorAfterCommonPostConfigurator::class) ->autowire() ->autoconfigure() ->private() - ->tag(EasyAdminExtension::TAG_FIELD_CONFIGURATOR, ['priority' => -10_000]); // must be after \EasyCorp\Bundle\EasyAdminBundle\Field\Configurator\CommonPreConfigurator + ->tag(self::TAG_FIELD_CONFIGURATOR, ['priority' => -10_000]); // must be after \EasyCorp\Bundle\EasyAdminBundle\Field\Configurator\CommonPreConfigurator } } diff --git a/tests/Resources/Views/Crud/Field/Expected/testOutput-no-data-since-easyadmin-5.8-1.html b/tests/Resources/Views/Crud/Field/Expected/testOutput-no-data-since-easyadmin-5.8-1.html new file mode 100644 index 0000000..ba81f41 --- /dev/null +++ b/tests/Resources/Views/Crud/Field/Expected/testOutput-no-data-since-easyadmin-5.8-1.html @@ -0,0 +1 @@ +Null diff --git a/tests/Resources/Views/Crud/Field/JsonFieldTest.php b/tests/Resources/Views/Crud/Field/JsonFieldTest.php index 962d7c9..dc4afb7 100644 --- a/tests/Resources/Views/Crud/Field/JsonFieldTest.php +++ b/tests/Resources/Views/Crud/Field/JsonFieldTest.php @@ -4,11 +4,14 @@ namespace Protung\EasyAdminPlusBundle\Tests\Resources\Views\Crud\Field; +use EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle; use Generator; use PHPUnit\Framework\Attributes\DataProvider; use Protung\EasyAdminPlusBundle\Field\JsonField; use Speicher210\FunctionalTestBundle\Test\Twig\TemplateTestCase; +use function version_compare; + final class JsonFieldTest extends TemplateTestCase { /** @@ -16,7 +19,12 @@ final class JsonFieldTest extends TemplateTestCase */ public static function dataProviderTestOutput(): Generator { - yield 'no-data' => [[]]; + // EasyAdmin 5.8 changed the CSS classes of the badge that the null label renders. + if (version_compare(EasyAdminBundle::VERSION, '5.8.0', '<')) { + yield 'no-data' => [[]]; + } else { + yield 'no-data-since-easyadmin-5.8' => [[]]; + } yield 'with-value' => [ [