Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple extension to be registered for the same page/resource #2135

Open
wants to merge 2 commits into
base: 1.x
Choose a base branch
from

Conversation

alecritson
Copy link
Collaborator

Currently when registering extensions in the panel, they are identified by the class to be extended as the array key, for example:

LunarPanel::extensions([
  CustomerResource::class => ExtensionA::class,
]);

This means you cannot register muliple extensions at once and would need to call extensions multiple times:

LunarPanel::extensions([
  CustomerResource::class => ExtensionA::class,
]);

LunarPanel::extensions([
  CustomerResource::class => ExtensionB::class,
]);

This PR looks to introduce changes so you can pass an array of extensions instead, meaning it can all be done in one call:

LunarPanel::extensions([
  CustomerResource::class => [ExtensionA:class, ExtensionB::class],
]);

Other notable tweaks

  • Added a check that the extension class exists before registering to minimise exceptions
  • Use app($extension) instead of new $extension to initialise the extension class.

@alecritson alecritson requested a review from glennjacobs March 17, 2025 09:31
Copy link

vercel bot commented Mar 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 17, 2025 11:48am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants