Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2178a94

Browse files
committed
Merge branch '4.x' into 5.x
* 4.x: Introduce an AdminControllerRegistry Bump development version Rebuild web assets Prepare 4.28.1 release Fix entity translation feature Fix field processing Add a test for the FormLayoutFactory label translation fix Refactor label translation handling in FormLayoutFactory Move Inspector\DataCollector to DataCollector\EasyAdminDataCollector Deprecate unused method ActionCollection::getEntityActions() More fixes for Symfony 5.4 tests Fix tests when using old Doctrine versions Add tests for the UUID format handling in autocomplete Fix UUID format handling in autocomplete for native GUID platforms Change overflow behavior to default on > 992px breakpoint for .sidebar Use Action constants over strings where possible Fix action confirmation messages in action groups Respect the showFlag/showName Country options in form pages
2 parents ca5874d + 2916dbf commit 2178a94

48 files changed

Lines changed: 1335 additions & 228 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ make checks-before-pr
132132
- Braces required for all control structures
133133
- Trailing commas in multi-line arrays
134134
- Blank line before `return` (unless only statement in block)
135+
- Don't add comments in classes as separators (e.g. `// === Methods for dashboards ===`)
135136

136137
### Naming
137138
- Variables/methods: `camelCase`

assets/css/easyadmin-theme/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ body:not(.ea-content-width-full) .content-wrapper {
207207
position: static;
208208
z-index: calc(var(--zindex-modal-backdrop) - 1);
209209
inline-size: initial;
210+
overscroll-behavior: auto;
210211
}
211212
}
212213
body.ea-mobile-sidebar-visible .sidebar {

config/services.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface;
1212
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemMatcherInterface;
1313
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityPaginatorInterface;
14-
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Provider\AdminContextProviderInterface;
1514
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Translation\EntityTranslationIdGeneratorInterface;
15+
use EasyCorp\Bundle\EasyAdminBundle\DataCollector\EasyAdminDataCollector;
1616
use EasyCorp\Bundle\EasyAdminBundle\DependencyInjection\EasyAdminExtension;
1717
use EasyCorp\Bundle\EasyAdminBundle\EventListener\AdminRouterSubscriber;
1818
use EasyCorp\Bundle\EasyAdminBundle\EventListener\CrudResponseListener;
@@ -72,7 +72,6 @@
7272
use EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType;
7373
use EasyCorp\Bundle\EasyAdminBundle\Form\Type\FileUploadType;
7474
use EasyCorp\Bundle\EasyAdminBundle\Form\Type\FiltersFormType;
75-
use EasyCorp\Bundle\EasyAdminBundle\Inspector\DataCollector;
7675
use EasyCorp\Bundle\EasyAdminBundle\Intl\IntlFormatter;
7776
use EasyCorp\Bundle\EasyAdminBundle\Maker\ClassMaker;
7877
use EasyCorp\Bundle\EasyAdminBundle\Menu\MenuItemMatcher;
@@ -81,25 +80,22 @@
8180
use EasyCorp\Bundle\EasyAdminBundle\Orm\EntityUpdater;
8281
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
8382
use EasyCorp\Bundle\EasyAdminBundle\Provider\FieldProvider;
83+
use EasyCorp\Bundle\EasyAdminBundle\Registry\AdminControllerRegistry;
8484
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminRouteGenerator;
8585
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminRouteLoader;
8686
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
87-
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface;
8887
use EasyCorp\Bundle\EasyAdminBundle\Security\AuthorizationChecker;
8988
use EasyCorp\Bundle\EasyAdminBundle\Security\SecurityVoter;
9089
use EasyCorp\Bundle\EasyAdminBundle\Translation\EntityTranslationIdGenerator;
9190
use EasyCorp\Bundle\EasyAdminBundle\Twig\Component\Alert;
9291
use EasyCorp\Bundle\EasyAdminBundle\Twig\Component\Flag;
9392
use EasyCorp\Bundle\EasyAdminBundle\Twig\Component\Icon;
9493
use EasyCorp\Bundle\EasyAdminBundle\Twig\EasyAdminTwigExtension;
95-
use Psr\Cache\CacheItemPoolInterface;
9694
use Symfony\Component\DependencyInjection\ContainerInterface;
9795
use Symfony\Component\DependencyInjection\Reference;
9896
use Symfony\Component\DependencyInjection\ServiceLocator;
9997
use Symfony\Component\HttpKernel\Event\ViewEvent;
10098
use Symfony\Component\HttpKernel\KernelInterface;
101-
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
102-
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;
10399

104100
return static function (ContainerConfigurator $container) {
105101
$services = $container->services()
@@ -123,7 +119,7 @@
123119
->arg(0, service(KernelInterface::class))
124120
->arg(1, param('kernel.project_dir'))
125121

126-
->set(DataCollector::class)
122+
->set(EasyAdminDataCollector::class)
127123
->arg(0, service(AdminContextProvider::class))
128124
->tag('data_collector', ['id' => 'easyadmin', 'template' => '@EasyAdmin/inspector/data_collector.html.twig'])
129125

@@ -187,11 +183,12 @@
187183
->set(AdminContextFactory::class)
188184
->arg(0, new Reference('security.token_storage', ContainerInterface::NULL_ON_INVALID_REFERENCE))
189185
->arg(1, new Reference(MenuFactory::class))
190-
->arg(2, new Reference(EntityFactory::class))
191-
->arg(3, service(AdminRouteGenerator::class))
192-
->arg(4, service(ActionFactory::class))
193-
->arg(5, service(EntityTranslationIdGeneratorInterface::class))
194-
->arg(6, service('cache.easyadmin'))
186+
->arg(2, new Reference(AdminControllerRegistry::class))
187+
->arg(3, new Reference(EntityFactory::class))
188+
->arg(4, service(AdminRouteGenerator::class))
189+
->arg(5, service(ActionFactory::class))
190+
->arg(6, service(EntityTranslationIdGeneratorInterface::class))
191+
->arg(7, service('cache.easyadmin'))
195192

196193
->set(AdminUrlGenerator::class)
197194
// I don't know if we truly need the share() method to get a new instance of the
@@ -200,8 +197,9 @@
200197
->share(false)
201198
->arg(0, service(AdminContextProvider::class))
202199
->arg(1, service('router'))
203-
->arg(2, service(AdminRouteGenerator::class))
204-
->arg(3, service('cache.easyadmin'))
200+
->arg(2, service(AdminControllerRegistry::class))
201+
->arg(3, service(AdminRouteGenerator::class))
202+
->arg(4, service('cache.easyadmin'))
205203

206204
->set('service_locator_'.AdminUrlGenerator::class, ServiceLocator::class)
207205
->args([[AdminUrlGenerator::class => service(AdminUrlGenerator::class)]])
@@ -211,6 +209,11 @@
211209
->parent('cache.system')
212210
->tag('cache.pool')
213211

212+
->set(AdminControllerRegistry::class)
213+
->arg(0, '%kernel.build_dir%')
214+
->arg(1, abstract_arg('CRUD controller FQCN to Entity FQCN map'))
215+
->arg(2, abstract_arg('Dashboard controller FQCNs'))
216+
214217
->set(AdminRouteGenerator::class)
215218
->arg(0, tagged_iterator(EasyAdminExtension::TAG_DASHBOARD_CONTROLLER))
216219
->arg(1, tagged_iterator(EasyAdminExtension::TAG_CRUD_CONTROLLER))
@@ -229,6 +232,7 @@
229232
->arg(3, service(AdminUrlGenerator::class))
230233
->arg(4, service(MenuItemMatcherInterface::class))
231234
->arg(5, service('cache.easyadmin'))
235+
->arg(6, service(EntityTranslationIdGeneratorInterface::class))
232236

233237
->set(MenuItemMatcher::class)
234238
->arg(0, service(AdminUrlGenerator::class))
@@ -357,8 +361,6 @@
357361
->arg(1, new Reference(AuthorizationChecker::class))
358362
->arg(2, new Reference('security.csrf.token_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE))
359363

360-
->set(CollectionConfigurator::class)
361-
362364
->set(CommonPostConfigurator::class)
363365
->arg(0, service(AdminContextProvider::class))
364366
->arg(1, '%kernel.charset%')

doc/dashboards.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ class name)* of the CRUD controller, you must pass the FQCN of the Doctrine
623623
entity associated to the CRUD controller::
624624

625625
use App\Entity\Category;
626+
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
626627
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
627628

628629
public function configureMenuItems(): iterable
@@ -635,10 +636,10 @@ entity associated to the CRUD controller::
635636

636637
// links to a different CRUD action
637638
MenuItem::linkToCrud('Add Category', 'fa fa-tags', Category::class)
638-
->setAction('new'),
639+
->setAction(Action::NEW),
639640

640641
MenuItem::linkToCrud('Show Main Category', 'fa fa-tags', Category::class)
641-
->setAction('detail')
642+
->setAction(Action::DETAIL)
642643
->setEntityId(1),
643644

644645
// if the same Doctrine entity is associated to more than one CRUD controller,

doc/fields/CountryField.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ to hide the flag::
9898

9999
yield CountryField::new('...')->showFlag(false);
100100

101+
// hide it in form pages only
102+
yield CountryField::new('...')->showFlag(Crud::PAGE_NEW !== $pageName && Crud::PAGE_EDIT !== $pageName);
103+
101104
showName
102105
~~~~~~~~
103106

@@ -107,6 +110,9 @@ to hide the name::
107110

108111
yield CountryField::new('...')->showName(false);
109112

113+
// show it only in form pages
114+
yield CountryField::new('...')->showFlag(Crud::PAGE_NEW === $pageName || Crud::PAGE_EDIT === $pageName);
115+
110116
useAlpha3Codes
111117
~~~~~~~~~~~~~~
112118

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/entrypoints.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"entrypoints": {
33
"app": {
44
"css": [
5-
"/app.58347242.css"
5+
"/app.cf59bc42.css"
66
],
77
"js": [
88
"/app.8c79e3ec.js"

public/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"app.css": "app.58347242.css",
2+
"app.css": "app.cf59bc42.css",
33
"app.js": "app.8c79e3ec.js",
44
"form.js": "form.5bccac01.js",
55
"page-layout.js": "page-layout.6e9fe55d.js",

src/Collection/ActionCollection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public function getIterator(): \ArrayIterator
8181
return new \ArrayIterator($this->actions);
8282
}
8383

84+
/**
85+
* @deprecated since 4.28.1 and will be removed in 5.0.0 without replacement
86+
*/
8487
public function getEntityActions(): self
8588
{
8689
return self::new(array_filter(

src/Context/AdminContext.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace EasyCorp\Bundle\EasyAdminBundle\Context;
44

5-
use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu;
6-
use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA;
75
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Context\AdminContextInterface;
86
use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDto;
97
use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDto;
@@ -13,6 +11,7 @@
1311
use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDto;
1412
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
1513
use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDto;
14+
use EasyCorp\Bundle\EasyAdminBundle\Registry\AdminControllerRegistry;
1615
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\Security\Core\User\UserInterface;
1817

@@ -76,9 +75,9 @@ public function getSearch(): ?SearchDto
7675
return $this->crudContext->getSearch();
7776
}
7877

79-
public function getCrudControllers(): CrudControllerRegistry
78+
public function getAdminControllers(): AdminControllerRegistry
8079
{
81-
return $this->crudContext->getCrudControllers();
80+
return $this->crudContext->getAdminControllers();
8281
}
8382

8483
public function getMainMenu(): MainMenuDto
@@ -166,6 +165,25 @@ public function isUseEntityTranslations(): bool
166165
return $this->dashboardContext->getDashboardDto()->isUseEntityTranslations();
167166
}
168167

168+
/**
169+
* Returns a new AdminContext with a different EntityDto.
170+
* Useful for nested CRUD operations (e.g., CollectionField).
171+
*/
172+
public function withEntity(EntityDto $entityDto): self
173+
{
174+
return new self(
175+
$this->requestContext,
176+
new CrudContext(
177+
$this->crudContext->getCrud(),
178+
$entityDto,
179+
$this->crudContext->getSearch(),
180+
$this->crudContext->getAdminControllers(),
181+
),
182+
$this->dashboardContext,
183+
$this->i18nContext,
184+
);
185+
}
186+
169187
/**
170188
* Creates an AdminContext instance suitable for testing.
171189
*

0 commit comments

Comments
 (0)