CP-17501 datamapper events - #17506
Merged
Merged
Conversation
This reverts commit 7e35277ee1cde48b249afb368e5a26b8a3b90f9b.
This reverts commit f1f0eb95ded53dc035f7502d10a341408f9ea0f8.
Assisted-by: Claude Code
Assisted-by: Claude Code
Assisted-by: Claude Code
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.
Hello!
In raising this pull request, I confirm the following:
Added lifecycle events to the DataMapper connections, fired through
Phalcon\Events\Managerand named on the newPhalcon\DataMapper\Pdo\Eventsclass:dm:beforeConnect/dm:afterConnect,dm:beforeDisconnect/dm:afterDisconnect,dm:beforePerform/dm:afterPerform,dm:beforeExec/dm:afterExec,dm:beforeQuery/dm:afterQuery,dm:beforeBeginTransaction/dm:afterBeginTransaction,dm:beforeCommit/dm:afterCommit,dm:beforeRollBack/dm:afterRollBackanddm:connectionLost.prepare()has no events of its own becauseperform()calls it, which would report one operation twice. The connect, disconnect and connectionLost events report a change of the connection state and fire whichever method causes it, so an automatic reconnect reports the lost connection and the new one.Phalcon\DataMapper\Pdo\Connection\Decorateddoes not fire the connect and disconnect events because it never connects and cannot disconnect.Added
getEventsManager()andsetEventsManager()toPhalcon\DataMapper\Pdo\Connection\AbstractConnection, and therefore toPhalcon\DataMapper\Pdo\ConnectionandPhalcon\DataMapper\Pdo\Connection\Decorated, and toPhalcon\DataMapper\Pdo\ConnectionLocator, which gives its events manager to every connection it returns, including the ones it builds on demand. The two classes now carry thePhalcon\Contracts\Events\EventsAwarecontract.Phalcon\DataMapper\Pdo\Connection\ConnectionInterfaceis unchanged, so classes that implement it directly keep workingAdded
Phalcon\DataMapper\Pdo\Exception\OperationCancelled, thrown when a listener cancels one of thebefore*events. The operation does not run. To cancel, a listener must call$event->stop()and also returnfalse:stop()alone returns the value of the listener, which the connection cannot tell apart from "no listeners", andfalsealone is replaced by any later listener that returns a value while the events manager is not instopOnFalsemode. Theafter*events are not cancellableThanks