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
4 changes: 3 additions & 1 deletion config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemMatcherInterface;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityPaginatorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Provider\FieldProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\DependencyInjection\EasyAdminExtension;
use EasyCorp\Bundle\EasyAdminBundle\EventListener\AdminRouterSubscriber;
use EasyCorp\Bundle\EasyAdminBundle\EventListener\CrudResponseListener;
Expand Down Expand Up @@ -281,7 +282,8 @@
->arg(2, tagged_iterator(EasyAdminExtension::TAG_FIELD_CONFIGURATOR))
->arg(3, service(FormLayoutFactory::class))

->set(FieldProvider::class)
->set(FieldProviderInterface::class)
->class(FieldProvider::class)
->arg(0, service(AdminContextProvider::class))

->set(FilterFactory::class)
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
13 changes: 13 additions & 0 deletions src/Contracts/Provider/FieldProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Provider;

use EasyCorp\Bundle\EasyAdminBundle\Field\Field;

interface FieldProviderInterface
{
/**
* @return array<Field>
*/
public function getDefaultFields(string $pageName): array;
}
6 changes: 3 additions & 3 deletions src/Controller/AbstractCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\CrudControllerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Provider\FieldProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\BatchActionDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
Expand Down Expand Up @@ -47,7 +48,6 @@
use EasyCorp\Bundle\EasyAdminBundle\Orm\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Orm\EntityUpdater;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Provider\FieldProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand Down Expand Up @@ -96,7 +96,7 @@ public function configureFilters(Filters $filters): Filters

public function configureFields(string $pageName): iterable
{
return $this->container->get(FieldProvider::class)->getDefaultFields($pageName);
return $this->container->get(FieldProviderInterface::class)->getDefaultFields($pageName);
}

public static function getSubscribedServices(): array
Expand All @@ -111,7 +111,7 @@ public static function getSubscribedServices(): array
EntityFactory::class => '?'.EntityFactory::class,
EntityRepository::class => '?'.EntityRepository::class,
EntityUpdater::class => '?'.EntityUpdater::class,
FieldProvider::class => '?'.FieldProvider::class,
FieldProviderInterface::class => '?'.FieldProviderInterface::class,
FilterFactory::class => '?'.FilterFactory::class,
FormFactory::class => '?'.FormFactory::class,
PaginatorFactory::class => '?'.PaginatorFactory::class,
Expand Down
6 changes: 2 additions & 4 deletions src/Provider/FieldProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
use Doctrine\DBAL\Types\Types;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Provider\AdminContextProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Provider\FieldProviderInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;

/**
* @author Javier Eguiluz <[email protected]>
*/
final class FieldProvider
final class FieldProvider implements FieldProviderInterface
{
public function __construct(
private readonly AdminContextProviderInterface $adminContextProvider,
) {
}

/**
* @return array<Field>
*/
public function getDefaultFields(string $pageName): array
{
$defaultPropertyNames = [];
Expand Down
Loading