Conversation
…erver - Remove the global ORMSubject singleton; observer dispatch now flows through ObserverBridge, a DatabaseEventObserverInterface implementation attached per DatabaseExecutor - Query builders return OrmSqlStatement (extends SqlStatement) stamped with the ORM event and affected table - All writes now notify: save(), delete(), deleteByQuery(), bulkExecute() (after commit), buildAndExecute() and built statements executed directly on the executor - save() keeps its previous semantics via deferred dispatch: observers receive the entity rehydrated with generated keys - New ObserverEvent::SoftDelete case: soft deletes now fire an event - New StatementHookInterface: before-execute hook with veto (throwing aborts the write) - Repository::addObserver() also accepts raw DatabaseEventObserverInterface; new Repository::removeObserver(); addDbDriverForWrite() re-attaches observers to the new write executor - ObserverData::getStatement() exposes the SQL statement to observers - Require byjg/anydataset-db ^7.0 and migrate tests/docs off the driver query methods removed in that release
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.
Summary
Version 7.0 rewires the entire observer system on top of the low-level
DatabaseExecutorobserver frombyjg/anydataset-db7.0, and migrates off the driver query methods removed in that release.ORMSubjectremoved: dispatch now flows throughObserverBridge, aDatabaseEventObserverInterfaceimplementation attached one-per-DatabaseExecutor(tracked in aWeakMap— no global state, nothing to clear in tests)save(),delete(),deleteByQuery(),bulkExecute()(after commit, nothing on rollback),buildAndExecute(), and built statements executed directly on the executorsave(): deferred dispatch keeps notifying after key rehydration, so Insert observers still receive the entity with its generated PKOrmSqlStatement: every builderbuild()returns it, stamped with the ORM event and affected table; exposed to observers viaObserverData::getStatement()ObserverEvent::SoftDelete: soft deletes now fire an event (previously silent)StatementHookInterface: before-execute hook with full SQL/params access; throwing vetoes the writeRepository::addObserver()also accepts a rawDatabaseEventObserverInterface; newremoveObserver()ObserverProcessorInterfaceimplementations require no code change. Breaking changes and the migration table are documented inCHANGELOG-7.0.md.Breaking changes
ORMSubjectremoved (includingclearObservers())DatabaseExecutorinstances no longer cross-notifyRepositoryprotected helpersinsert()/insertWithAutoInc()/insertWithKeyGen()/update()now receive the pre-builtOrmSqlStatementbyjg/anydataset-db: ^7.0(driver query methods removed upstream)Test plan
tests/ObserverBridgeTest.php: soft delete event, direct executor writes, bulk commit/rollback, per-executor scoping, veto hook,getStatement(), raw passthrough,addDbDriverForWrite()re-attach,onError()swallowinganydataset-db7.0.x-dev; Psalm clean