Skip to content

feat: add the PSR-14 table gateway event dispatcher feature - #9

Merged
tyrsson merged 5 commits into
1.0.xfrom
feat/event-dispatcher-feature
Oct 9, 2026
Merged

tyrsson merged 5 commits into
1.0.xfrom
feat/event-dispatcher-feature

Conversation

@tyrsson

@tyrsson tyrsson commented Oct 9, 2026

Copy link
Copy Markdown
Member

Migrates the EventDispatcher feature from webinertia/phpdb-feature (0.1.x, the finish-event-dispatcher line) into the PhpDb bridge.

Where it lands

Under the PhpDb\ root this package shadows, named beside php-db's own laminas-based EventFeature:

Migrated from webware/phpdb-feature Lands as
Webware\PhpDb\Feature\EventDispatcherFeature PhpDb\TableGateway\Feature\EventDispatcherFeature
Webware\PhpDb\Feature\EventDispatcher\TableGatewayEvent PhpDb\TableGateway\Feature\EventDispatcher\TableGatewayEvent
  • EventDispatcherFeature implements php-db's EventFeatureEventsInterface, so a table gateway accepts it exactly where php-db's feature is accepted, and publishes each lifecycle hook through a composed PSR-14 dispatcher rather than a laminas event manager.
  • TableGatewayEvent extends Webware\Event\Event, carrying the hook name, the gateway as target, and the hook's arguments keyed as EventFeature keys them.

The source branch's RelatedTable\* group is not migrated: it imports PhpDb\RepositoryInterface, which php-db 0.6.x does not ship, and it stays in webware/phpdb-feature untouched.

Dependencies

webware/webware-event is require-dev plus a suggest, not a runtime require — this package's own tests exercise the feature, and a consumer that uses it supplies its own dispatcher.

The lock also moves to webware/webware-tools 1.0.0-rc.2, which resets the tool pin this repo extends to Mago 1.54.0. Supersedes #8, which bumped to the older 1.0.0-beta.10. The six test files the formatter reshapes under that pin ((new X())() to new X()()) are included.

Verification, under the pinned Mago 1.54.0

Gate Result
format --check exit 0 — all files formatted
lint exit 0 — no issues (one inline @mago-expect lint:too-many-methods, the hook set the interface fixes)
analyze exit 0 — one new baseline entry for php-db's AbstractFeature::$tableGateway, which FeatureSet::setTableGateway() assigns after construction; the 9 pre-existing warnings/helps still report live and unchanged
guard exit 0 — no issues
PHPUnit unit + integration OK (95 tests, 196 assertions, 2 skipped)
Infection Mutation Code Coverage 100%, Covered MSI 99% against the 95 floor; 203 of 204 mutants killed

The single escaped mutant is in SchemaFactory, pre-existing and untouched by this branch.

Migrates the EventDispatcher feature from webinertia/phpdb-feature (0.1.x)
into the PhpDb bridge, placed under the `PhpDb\` root this package shadows
and named beside php-db's own laminas-based EventFeature:

- `PhpDb\TableGateway\Feature\EventDispatcherFeature` implements php-db's
  EventFeatureEventsInterface and publishes each lifecycle hook through a
  PSR-14 dispatcher instead of a laminas event manager.
- `PhpDb\TableGateway\Feature\EventDispatcher\TableGatewayEvent` is the event
  each hook is published as: the hook name, the table gateway as target, and
  the hook's arguments keyed as EventFeature keys them.

`webware/webware-event` is require-dev plus a suggestion, not a runtime
require: this package's own tests exercise the feature, and a consumer that
uses it supplies its own event dispatcher.

The lock moves to webware/webware-tools 1.0.0-rc.2 in the same update, which
resets the tool pin this repo extends to Mago 1.54.0; the test files the
formatter reshapes under that version are included. One analyzer baseline
entry covers php-db's `AbstractFeature::$tableGateway`, which FeatureSet
assigns after construction.

Signed-off-by: Joey Smith <jsmith@webinertia.net>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

tyrsson and others added 4 commits October 8, 2026 21:30
Six topics under docs/v1: the shadow and what ships, installation, the schema factory, the session persistence and its table, the PSR-14 table gateway event feature, and development.

Every statement was checked against the code, including the SchemaFactory exception paths and the backup prefix fallbacks, which were measured rather than inferred.

Signed-off-by: Joey Smith <jsmith@webinertia.net>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The README now carries the quickstart: install, merge the providers, build an identifier from a schema enum, create the session table. It then links the six pages under docs/v1.

The old Installation section claimed WebwareProvider must be registered after PhpDb\\ConfigProvider for its rules to win. The two share no config keys, so that ordering requirement was not real; the README now says so, and the ordering note it keeps is the one that does exist, SessionProvider after the Mezzio session providers.

The seven em dashes in the README are replaced, matching the rule applied to docs/v1.

Each quickstart step was executed before committing: the merged aggregator resolves SchemaFactory through the container, the enum yields 'acl_role' with no prefix configured and 'acl' as its schema, and SessionProvider registers both the SessionPersistenceInterface alias and the session:init-db command.

Signed-off-by: Joey Smith <jsmith@webinertia.net>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The schema and event examples borrowed webware-acl's table name, and one borrowed webware-core's. Neither component is a collaborator of this bridge, so the examples now use the tables this package owns: WebwareSchema with a 'webware' schema and a 'session' case, and PhpDb\\Session\\SessionTable for the enum that leaves NAME at its default.

The SchemaFactory docblock carried the same borrowed name and is updated with it.

Every example was executed against the working tree before committing: with prefix 'ww' the enum yields 'ww_session' and schema 'webware'; per-table overrides yield 'sess_session' and 'tenant'; a call-time prefix yields 'x_session'; backup with 'bck' yields 'bck_session' and schema 'backup'; a backup with no backup_prefix yields 'session' with a null prefix; the shipped SessionTable yields a null schema; and an empty case value still raises Psl\\Type\\Exception\\AssertException.

Signed-off-by: Joey Smith <jsmith@webinertia.net>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bles

The fixtures carried webware-acl's and webware-core's names, neither of which is a collaborator of this bridge, and they were the source the docs had copied. They now use the table this package owns:

- AclSchema, no NAME, becomes DefaultSchema with case Session = 'session'.
- PublicSchema, which exercises the NAME constant, becomes WebwareSchema with NAME = 'webware', matching the example in docs/v1.
- EmptySchema and IntSchema keep their purpose names and take case Session, so their values stay empty and int-backed.
- The integration fixture becomes IntegrationSchema with case Session, and its DDL assertions move from ww_core_role to ww_session.

SchemaFactoryTest and SchemaFactoryFactoryTest follow: per-table overrides are keyed 'session', and the NAME assertion now expects 'webware'.

The schema fixture that leaves NAME alone produces a null schema, which is what the shipped PhpDb\\Session\\SessionTable does, so the pair now mirrors the package rather than an unrelated component.

Verified locally: four Mago gates clean, unit suite OK (67 tests), integration suite OK (28 tests, 2 skipped for the disabled adapters), Infection Coverage 100% and Covered MSI 99% unchanged. The MySQL integration round-trip created and dropped ww_session, leaving the database empty.

Signed-off-by: Joey Smith <jsmith@webinertia.net>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tyrsson
tyrsson merged commit 0b4321d into 1.0.x Oct 9, 2026
12 checks passed
@tyrsson
tyrsson deleted the feat/event-dispatcher-feature branch October 9, 2026 04:41
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