Closed rishta closed 2 years ago
I agree some your concerns, but there's a lot of workarounds to say "badly written".
For example, you can easily ovveride AbstractCrudController::autocomplete()
to make the code according your logic. Alternatively you can listen to AfterEntitySearchEvent
and modify QueryBuilder as you need.
Do you have any ideas to modify autocompletes?
Regarding your suggestions:
This feature is half baked to the point of food poisoning. Yes, IT IS BADLY WRITTEN, because it forces the developer firstly - to take care of such inconsistencies, secondly - to reinvent the wheel instead of using IC.
My suggestion is:
How:
formatValue()
in AbstractEntityDto (for example),AutocompleteDto extends AbstractEntityDto implements AutocompleteDtoInterface
Currently "Easy" is not an attribute of this package.
@rishta I look forward to your pull request
@rishta I'm sorry this project doesn't fit your needs. Luckily there are many other open source projects that you could try. E.g. for Symfony apps you have SonataAdminBundle and Api Platform Admin. Cheers!
A very French approach to criticism. Déjalo. XD
ApiPlatform has the same closed "design" as EasyAdmin: example - not possible to add HTTP methods (LINK, UNLINK) as extension. No, thanks.
The problem: autocomplete in EA3 doesn't work well and cannot be easily extended.
Suppose I have a entity
Customer(phone, name, lastname, email, ...)
. I want to useCustomer
in a create form for anOrder
:formatValue
makes the autocomplete database query match whatever the closure returns (in my case I want to search in phone number and full name). However, there's the second part of that, because the query results are NOT returned to the client using this same method, but are passed to**final class** EntityDto
with this naïve implementation:This final class is used in another final class
EntityPaginator
. This class does implement EntityPaginatorInterface, but there is no AbstractEntityPaginator, so it cannot be extended short of reimplementing the whole interface. At this point I am forced to code the whole autocomplete by hand, because the built-in one is inconsistent and I cannot inject myEntityDto
into the logic to fix it.I understand SOLID etc., but this kind of carelessness in making final classes is insane! Completely closing such functionality without leaving any abstraction makes DependencyInjection noting but a feeble dream of a madman. The library loses all extensibility.
Two point conclusion: