Replies: 1 comment
-
Really usefull to me |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Description
Filament has excellent support for dependency injection in most actions. However, when we attempt to customize the default
CreateRecord
orEditRecord
pages by injecting application-specific classes, it results in an error.Example of the code:
The application fails to resolve the constructor parameters, producing an error similar to the following:
This feature is essential when working with complex domain logic, as it allows us to separate the logic from the Filament page itself while retaining all the default page features.
Current Workarounds
To handle this limitation, developers typically resort to:
While these workarounds are functional, they can introduce unnecessary complexity in scenarios where dependency injection could simplify the process by allowing us to directly inject the required classes into the page constructors.
Proposed Solution
To address this issue, I propose making small changes to the following files to enable support for dependency injection in page constructors:
SupportPageComponents
(Livewire\Features\SupportPageComponents\SupportPageComponents.php
):gatherMountMethodParamsFromRouteParameters
method.resolvePageComponentRouteBindings
method.ComponentRegistry
(Livewire\Mechanisms\ComponentRegistry.php
):new
method.In a few words, we suggest chaging the lines like:
These changes would allow Filament pages to utilize the full benefits of dependency injection, improving flexibility and reducing reliance on complex workarounds.
Benefits
Conclusion
This feature would enhance Filament's flexibility and usability for developers working on complex applications, aligning with modern software development practices. Thank you for considering this request!
I would be glad to work in a pull request on this feature if needed.
Beta Was this translation helpful? Give feedback.
All reactions