diff --git a/config/services.php b/config/services.php index 63358166bf..df75546125 100644 --- a/config/services.php +++ b/config/services.php @@ -8,6 +8,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Cache\CacheWarmer; use EasyCorp\Bundle\EasyAdminBundle\Command\MakeAdminDashboardCommand; use EasyCorp\Bundle\EasyAdminBundle\Command\MakeCrudControllerCommand; +use EasyCorp\Bundle\EasyAdminBundle\Contracts\Factory\FieldFactoryInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemMatcherInterface; @@ -248,7 +249,7 @@ ->arg(4, service('event_dispatcher')) ->set(EntityFactory::class) - ->arg(0, service(FieldFactory::class)) + ->arg(0, service(FieldFactoryInterface::class)) ->arg(1, service(ActionFactory::class)) ->arg(2, service(AuthorizationChecker::class)) ->arg(3, service('doctrine')) @@ -275,7 +276,8 @@ ->set(FormLayoutFactory::class) - ->set(FieldFactory::class) + ->set(FieldFactoryInterface::class) + ->class(FieldFactory::class) ->arg(0, service(AdminContextProvider::class)) ->arg(1, service(AuthorizationChecker::class)) ->arg(2, tagged_iterator(EasyAdminExtension::TAG_FIELD_CONFIGURATOR)) diff --git a/src/Attribute/AdminDashboard.php b/src/Attribute/AdminDashboard.php index eef97709d7..dfdda6a268 100644 --- a/src/Attribute/AdminDashboard.php +++ b/src/Attribute/AdminDashboard.php @@ -12,11 +12,11 @@ public function __construct( /** * @var string|null $routePath The path of the Symfony route that will be created for the dashboard (e.g. '/admin) */ - public /* ?string */ $routePath = null, + /* ?string */ public $routePath = null, /** * @var string|null $routeName The name of the Symfony route that will be created for the dashboard (e.g. 'admin') */ - public /* ?string */ $routeName = null, + /* ?string */ public $routeName = null, /** * @var array{ * requirements?: array, diff --git a/src/Contracts/Factory/FieldFactoryInterface.php b/src/Contracts/Factory/FieldFactoryInterface.php new file mode 100644 index 0000000000..26541a43e2 --- /dev/null +++ b/src/Contracts/Factory/FieldFactoryInterface.php @@ -0,0 +1,15 @@ + $fields + */ + public function processFields(EntityDto $entityDto, FieldCollection $fields): void; +} diff --git a/src/Factory/EntityFactory.php b/src/Factory/EntityFactory.php index cec0d8e907..e8dcc4e969 100644 --- a/src/Factory/EntityFactory.php +++ b/src/Factory/EntityFactory.php @@ -9,6 +9,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\ActionCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; +use EasyCorp\Bundle\EasyAdminBundle\Contracts\Factory\FieldFactoryInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityBuiltEvent; @@ -23,13 +24,13 @@ */ final class EntityFactory { - private FieldFactory $fieldFactory; + private FieldFactoryInterface $fieldFactory; private ActionFactory $actionFactory; private AuthorizationCheckerInterface $authorizationChecker; private ManagerRegistry $doctrine; private EventDispatcherInterface $eventDispatcher; - public function __construct(FieldFactory $fieldFactory, ActionFactory $actionFactory, AuthorizationCheckerInterface $authorizationChecker, ManagerRegistry $doctrine, EventDispatcherInterface $eventDispatcher) + public function __construct(FieldFactoryInterface $fieldFactory, ActionFactory $actionFactory, AuthorizationCheckerInterface $authorizationChecker, ManagerRegistry $doctrine, EventDispatcherInterface $eventDispatcher) { $this->fieldFactory = $fieldFactory; $this->actionFactory = $actionFactory; diff --git a/src/Factory/FieldFactory.php b/src/Factory/FieldFactory.php index 7bd2088e36..cf2db4aafc 100644 --- a/src/Factory/FieldFactory.php +++ b/src/Factory/FieldFactory.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Types\Types; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; +use EasyCorp\Bundle\EasyAdminBundle\Contracts\Factory\FieldFactoryInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Provider\AdminContextProviderInterface; @@ -28,7 +29,7 @@ /** * @author Javier Eguiluz */ -final class FieldFactory +final class FieldFactory implements FieldFactoryInterface { /** * @var array> @@ -162,7 +163,11 @@ private function preProcessFields(FieldCollection $fields, EntityDto $entityDto) } } - // transforms a generic Field class into a specific Field class (e.g. DateTimeField) + /** + * transforms a generic Field class into a specific Field class (e.g. DateTimeField). + * + * @param class-string $newFieldFqcn + */ private function transformField(FieldDto $fieldDto, string $newFieldFqcn): FieldDto { /** @var FieldDto $newField */