TransactionSubscriber
in package
implements
EventSubscriberInterface
Class TransactionSubscriber
Implement transaction management for API calls. Two API options are accepted:
- is_transactional: bool|'nest' - if true, then all work is done inside a transaction. By default, true for mutator actions (C-UD). 'nest' will force creation of a nested transaction; otherwise, the default is to re-use any existing transactions.
- options.force_rollback: bool - if true, all work is done in a nested transaction which will be rolled back.
Table of Contents
Interfaces
- EventSubscriberInterface
Properties
- $forceRollback : array<string|int, mixed>
- (Unused?) A list of requests which should be forcibly rolled back to their save points.
- $transactions : array<string|int, mixed>
- List of active transaction objects.
Methods
- getSubscribedEvents() : array<string|int, mixed>
- isForceRollback() : bool
- Determine if caller wants us to *always* rollback.
- isNested() : bool
- Determine if caller wants a nested transaction or a re-used transaction.
- isTransactional() : bool
- Determine if an API request should be treated as transactional.
- onApiException() : mixed
- Rollback the pending transaction.
- onApiPrepare() : mixed
- Open a new transaction instance (if appropriate in the current policy)
- onApiRespond() : mixed
- Close any pending transactions.
Properties
$forceRollback
(Unused?) A list of requests which should be forcibly rolled back to their save points.
private
array<string|int, mixed>
$forceRollback
= []
array (scalar $apiRequestId => bool)
$transactions
List of active transaction objects.
private
array<string|int, mixed>
$transactions
= []
array(scalar $apiRequestId => CRM_Core_Transaction $tx)
Methods
getSubscribedEvents()
public
static getSubscribedEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>isForceRollback()
Determine if caller wants us to *always* rollback.
public
isForceRollback(ProviderInterface $apiProvider, array<string|int, mixed> $apiRequest) : bool
Parameters
- $apiProvider : ProviderInterface
-
The API provider responsible for this request.
- $apiRequest : array<string|int, mixed>
-
The full API request.
Return values
boolisNested()
Determine if caller wants a nested transaction or a re-used transaction.
public
isNested(ProviderInterface $apiProvider, array<string|int, mixed> $apiRequest) : bool
Parameters
- $apiProvider : ProviderInterface
-
The API provider responsible for this request.
- $apiRequest : array<string|int, mixed>
-
The full API request.
Return values
bool —True if a new nested transaction is required; false if active tx may be used
isTransactional()
Determine if an API request should be treated as transactional.
public
isTransactional(ProviderInterface $apiProvider, array<string|int, mixed> $apiRequest) : bool
Parameters
- $apiProvider : ProviderInterface
-
The API provider responsible for this request.
- $apiRequest : array<string|int, mixed>
-
The full API request.
Return values
boolonApiException()
Rollback the pending transaction.
public
onApiException(ExceptionEvent $event) : mixed
Parameters
- $event : ExceptionEvent
-
API exception event.
onApiPrepare()
Open a new transaction instance (if appropriate in the current policy)
public
onApiPrepare(PrepareEvent $event) : mixed
Parameters
- $event : PrepareEvent
-
API preparation event.
onApiRespond()
Close any pending transactions.
public
onApiRespond(RespondEvent $event) : mixed
Parameters
- $event : RespondEvent
-
API response event.