[symfony 7.3] Public constructor required in custom filter
Describe the bug When creating a custom filter, I have the error :
Invalid service "App\Foo": its constructor must be public. Did you miss configuring a factory or a static constructor? Try using the "#[Autoconfigure(constructor: ...)]" attribute for the latter.
To Reproduce Create a custom filter using the FilterTrait like in the documentation.
(OPTIONAL) Additional context It's maybe due to the symfony 7.3 version since this PR
Changing FilterTrait private constructor to public resolve the issue for me.
You can exclude the filter from autoconfiguring for a temporary workaround.
Ok but as you say it's for a temporary workaround. Is there something missing from my filter to avoid this error?
Hi, same issue.
Do we need to make a correction on easyadmin or on the app ?
Hi, same issue.
Do we need to make a correction on easyadmin or on the app ?
Like I said I change the easycorp/easyadmin-bundle/src/Filter/FilterTrait.php constructor to public and it's work if you want a temporary correction. For a long-term correction I don't know
@BaptisteChabrol can it be, that you have your custom filter in the Controller/Admin namespace?
I had the same error and when "solving" it with a custom FilterTrait and a public constructor .. just another problem popped up.
I think, the solution is actually, to move your custom filter (and fields) outside of the Controller namespace.. e.g. to Form\Admin than those are by design not part of the AutoConfiguration anymore. That solved it for me and seems logical, since a Field is not a Controller anyway.
There was somewhere else a bug report around DependencyInjection, which pointed me in that direction.