Commit 287f467
committed
feature #6769 Update admin dashboard (javiereguiluz)
This PR was squashed before being merged into the 4.x branch.
Discussion
----------
Update admin dashboard
When we moved to "pretty URLs", the recommended solution to define the dashboard route was this:
```php
// ...
use Symfony\Component\Routing\Attribute\Route;
class DashboardController extends AbstractDashboardController
{
#[Route('/admin', name: 'admin')]
public function index(): Response
{
return parent::index();
}
// ...
}
```
In the past weeks we've faced many issues related to the cache and the event listener related to admin URLs. The problem to solve is this: we need to find out very quickly (i.e. performant) and unequivocally if a given URLs belongs to an EasyAdmin backend or not.
When using pretty URLs, this is trivial because we generate those routes and apply some special route attributes to them. But, there's a missing route: the main dashboard route. That one is defined by the user and we cannot add those special attributes to it. Trust me, I tried this very hard (even asking internally to the Symfony Core Team). This is not possible technically speaking.
So, after thinking a lot about this, I propose to use the recently introduced `#[AdminDashboard]` attribute to define the admin route:
```php
use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminDashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
#[AdminDashboard(routePath: '/admin', routeName: 'admin')]
class DashboardController extends AbstractDashboardController
{
public function index(): Response
{
return parent::index();
}
// ...
}
```
This will solve all our problems, because this attribute will be used to generate the associated Symfony route. Since we create that route, we can apply the custom route attributes. This makes the caching hacks unnecessary and improves the performance of the application. So, I propose to add this now and make it mandatory in EasyAdmin 5.x as the only solution that works to define admin routes.
I know all these changes are tiring 😫 but this is the last time we'll change this and I think the change is worth it because it will solve all our internal issues related to admin routes 🙏
What do you think?
Commits
-------
901a892 Update admin dashboardFile tree
10 files changed
+358
-28
lines changed- doc
- src
- Attribute
- Resources/skeleton
- Router
- tests
- Controller/PrettyUrls
- PrettyUrlsTestApplication/src/Controller
10 files changed
+358
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
| 609 | + | |
609 | 610 | | |
610 | 611 | | |
611 | 612 | | |
| 613 | + | |
612 | 614 | | |
613 | 615 | | |
614 | 616 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| 557 | + | |
557 | 558 | | |
558 | 559 | | |
559 | 560 | | |
560 | 561 | | |
| 562 | + | |
561 | 563 | | |
562 | 564 | | |
563 | 565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 28 | + | |
| 29 | + | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | | - | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
106 | 123 | | |
107 | 124 | | |
108 | 125 | | |
| |||
114 | 131 | | |
115 | 132 | | |
116 | 133 | | |
117 | | - | |
118 | | - | |
| 134 | + | |
| 135 | + | |
119 | 136 | | |
120 | 137 | | |
121 | 138 | | |
122 | 139 | | |
123 | 140 | | |
124 | 141 | | |
125 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
126 | 170 | | |
127 | 171 | | |
128 | 172 | | |
| |||
315 | 359 | | |
316 | 360 | | |
317 | 361 | | |
| 362 | + | |
318 | 363 | | |
319 | 364 | | |
320 | 365 | | |
321 | 366 | | |
| 367 | + | |
322 | 368 | | |
323 | 369 | | |
324 | 370 | | |
| |||
409 | 455 | | |
410 | 456 | | |
411 | 457 | | |
| 458 | + | |
412 | 459 | | |
413 | 460 | | |
414 | 461 | | |
415 | 462 | | |
416 | 463 | | |
| 464 | + | |
417 | 465 | | |
418 | 466 | | |
419 | 467 | | |
| |||
424 | 472 | | |
425 | 473 | | |
426 | 474 | | |
427 | | - | |
428 | 475 | | |
429 | 476 | | |
430 | 477 | | |
| |||
459 | 506 | | |
460 | 507 | | |
461 | 508 | | |
| 509 | + | |
462 | 510 | | |
463 | 511 | | |
464 | 512 | | |
465 | 513 | | |
| 514 | + | |
466 | 515 | | |
467 | 516 | | |
468 | 517 | | |
469 | 518 | | |
470 | | - | |
471 | 519 | | |
472 | 520 | | |
473 | 521 | | |
| |||
504 | 552 | | |
505 | 553 | | |
506 | 554 | | |
| 555 | + | |
507 | 556 | | |
508 | 557 | | |
509 | 558 | | |
| 559 | + | |
510 | 560 | | |
511 | 561 | | |
512 | 562 | | |
| |||
789 | 839 | | |
790 | 840 | | |
791 | 841 | | |
| 842 | + | |
792 | 843 | | |
793 | 844 | | |
794 | 845 | | |
795 | 846 | | |
796 | 847 | | |
| 848 | + | |
797 | 849 | | |
798 | 850 | | |
799 | 851 | | |
| |||
899 | 951 | | |
900 | 952 | | |
901 | 953 | | |
| 954 | + | |
902 | 955 | | |
903 | 956 | | |
904 | 957 | | |
| |||
941 | 994 | | |
942 | 995 | | |
943 | 996 | | |
| 997 | + | |
944 | 998 | | |
945 | 999 | | |
946 | 1000 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
| 144 | + | |
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
| 148 | + | |
145 | 149 | | |
146 | 150 | | |
147 | 151 | | |
| |||
390 | 394 | | |
391 | 395 | | |
392 | 396 | | |
| 397 | + | |
393 | 398 | | |
394 | 399 | | |
395 | 400 | | |
| 401 | + | |
396 | 402 | | |
397 | 403 | | |
398 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
78 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
13 | 37 | | |
14 | 38 | | |
15 | 39 | | |
16 | 40 | | |
17 | 41 | | |
18 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
19 | 73 | | |
20 | 74 | | |
0 commit comments