Skip to content
Open
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
6 changes: 4 additions & 2 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'))
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/AdminDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>,
Expand Down
15 changes: 15 additions & 0 deletions src/Contracts/Factory/FieldFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Factory;

use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;

interface FieldFactoryInterface
{
/**
* @param FieldCollection<FieldDto> $fields
*/
public function processFields(EntityDto $entityDto, FieldCollection $fields): void;
}
5 changes: 3 additions & 2 deletions src/Factory/EntityFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions src/Factory/FieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +29,7 @@
/**
* @author Javier Eguiluz <[email protected]>
*/
final class FieldFactory
final class FieldFactory implements FieldFactoryInterface
{
/**
* @var array<string, class-string<FieldInterface>>
Expand Down Expand Up @@ -162,7 +163,11 @@ private function preProcessFields(FieldCollection $fields, EntityDto $entityDto)
}
}

// transforms a generic Field class into a specific <type>Field class (e.g. DateTimeField)
/**
* transforms a generic Field class into a specific <type>Field class (e.g. DateTimeField).
*
* @param class-string<FieldInterface> $newFieldFqcn
*/
private function transformField(FieldDto $fieldDto, string $newFieldFqcn): FieldDto
{
/** @var FieldDto $newField */
Expand Down
Loading