Skip to content

08: Registrar - #8

Open
nikolaystrikhar wants to merge 3 commits into
07-sub-pluginfrom
08-registrar
Open

08: Registrar#8
nikolaystrikhar wants to merge 3 commits into
07-sub-pluginfrom
08-registrar

Conversation

@nikolaystrikhar

@nikolaystrikhar nikolaystrikhar commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Adds the sub-plugin registry and its Registrar_Interface contract.

Stacked on #7.

$registrar = new Registrar();
$registrar->register( $sub_plugin );
$registrar->all();   // [ 'give-recurring' => Sub_Plugin ]
  • Keyed by slug. Re-registering the same slug replaces in place, so a host registering from two code paths gets one entry rather than two loads, and the order stays stable.
  • Load order is now documented. all() returns insertion order and Loader::load_all() require_onces in that order, so registering an add-on before the sub-plugin whose class it extends is a fatal at plugins_loaded. The README says so now, and two tests pin the order.

Registration order decides load order, and nothing said so where a host
would read it. A host registering an add-on before the plugin it extends
gets a class-not-found fatal at plugins_loaded.

Also explain on the contract why reset() is on it: a container-bound
singleton registrar survives a Loader reset, so an implementation that
no-ops reset() leaks registrations between boots.
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.

1 participant