MIDDAG for Moodle

transaction_manager_interface

Contract for the Transaction Manager.

Provides a clean and robust execution layer for Moodle's delegated transactions, transparently solving the "Implicit Rollback" conflicts and \Throwable incompatibilities.

Table of Contents

Methods

execute_atomic()  : T
Executes a callback inside a safe transaction boundary.
execute_graceful()  : T|Throwable
Executes a callback inside a transaction boundary and gracefully catches exceptions.

Methods

execute_atomic()

Executes a callback inside a safe transaction boundary.

public execute_atomic(callable(): T $operation) : T
Parameters
$operation : callable(): T

Core business logic to run

Tags
throws
Throwable

Any exception triggered by the operation

Return values
T

execute_graceful()

Executes a callback inside a transaction boundary and gracefully catches exceptions.

public execute_graceful(callable(): T $operation) : T|Throwable

If the transaction is the Outermost transaction, Moodle's native exception-throwing rollback is neutralized, avoiding LMS crashes and returning the Domain Exception or Result. If it's an Inner transaction (nested), Moodle inherently dooms the DB connection, so it predictably re-throws to honor Moodle's cascading rollback constraint.

Parameters
$operation : callable(): T

Core business logic to run

Return values
T|Throwable

returns the Throwable on graceful rollback instead of crashing


        
On this page

Search results