Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Render hooks are commonly used to customize the Filament experience further, especially inside of panels.
One limitation that I personally find with the
renderHook()method is that certain views require custom data and placing all of that logic inside of the panel provider or a service provider can become rather messy.A workaround for this that already exists is creating a class to handle the rendering, but it still requires some manual wiring to work correctly, especially when dependency injection is involved.
This pull request introduces the concept of a
RenderHookclass with support for auto-discovery.You create a class that extends
Filament\View\RenderHookand implement the necessary methods. You specify the hook(s) you want to render for and the View or string that should be rendered.Classes are resolved from the container so dependency injection works as expected and you can pull in service classes for data retrieval etc.
By adding
->discoverRenderHooks()onto yourPanelobject, specifying the directory and namespace, you get the real benefit of auto-discovered render hooks, removing the need for that superfluous method call.Visual changes
N/A
Functional changes
composer cscommand.