Add ResourceActionRegistry for package-contributed Resource actions - #87
Open
Ivanh00 wants to merge 1 commit into
Open
Add ResourceActionRegistry for package-contributed Resource actions#87Ivanh00 wants to merge 1 commit into
Ivanh00 wants to merge 1 commit into
Conversation
Plugins can register namespaced Resource actions through a singleton registry (Aura\Base\Contracts\ResourceActionRegistry) instead of mutating Resource classes. Resource-owned actions keep precedence on name collisions, contributed actions re-authorize server-side before execution, registrations are captured at boot and restored at worker boundaries like the other Aura state singletons, and the actions view no longer hides contributed actions behind the legacy ownership check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Commercial plugins (developed alongside Aura Reports) need to contribute Resource actions without mutating host Resource classes or shipping view overrides. Today, actions only come from
Resource::getActions(), so every plugin-added action requires touching core Resources.What this adds
Aura\Base\Contracts\ResourceActionRegistry— a small contract:register(),actionsFor($resource, $actor),execute($name, $resource, $actor), plus the boot/worker state hooks used by the other Aura singletons.Aura\Base\Services\ResourceActionRegistry— the singleton implementation. Plugins register namespaced action definitions (e.g.aura-reports.duplicate); duplicate names fail deterministically withResourceActionConflict.HasActionsintegration —getActionsProperty()merges contributed actions with Resource-owned ones (Resource-owned actions keep precedence on name collisions), andsingleAction()executes contributed actions through the registry. Contributed actions run a fresh server-side authorization check before execution; authorization failures abort with 403.captureBaselineState()), andAura::flushState()/ worker boundaries restore it, mirroringTeamScope/ScopedScopehandling. The provider binds the singleton and captures the baseline in the existingbootedhook.HasActionswhere contributed actions are also filtered for the actor.Security properties
conditional_logicon contributed definitions is evaluated like Resource-owned ones.Tests
tests/Feature/Resource/ResourceActionRegistryTest.phpcovers: contributed actions rendering for permitted actors, precedence on collisions, deterministic conflict failures, worker flush restoring the boot baseline, and execution authorization. Full local suite: 1825 passed, 4 skipped (browser tests run in CI; Playwright not installed locally).Developed while building the Aura Reports plugin — that plugin will consume this seam instead of overriding views.