CoolCMS API

TransactionManager
in package

Table of Contents

Properties

$closedByRollbackOnly  : bool
The last commit rolled the transaction back, so a following rollback by the caller is a no-op.
$entityManager  : EntityManagerInterface
$rollbackOnly  : bool
A nested level rolled back; the outermost commit rolls back instead of committing.
$transactionLevel  : int

Methods

__construct()  : mixed
begin()  : void
closeLeftoverTransaction()  : void
Safety net at the end of a request (`Application::onShutdown`, web/Api/cron).
commit()  : void
Counts levels: a nested commit only decrements. The real action happens at the outermost level: a commit, or a rollback when a nested level rolled back (an inner save failed). In that case {@see RollbackOnlyException} is thrown after the rollback so the caller does not report "saved" when nothing was saved.
getTransactionLevel()  : int
isInTransaction()  : bool
isRollbackOnly()  : bool
A nested level rolled back; the last commit rolls back.
rollback()  : void
Counts levels: a nested rollback only decrements and marks the transaction rollback-only.
discardUnitOfWork()  : void
Clears the whole unit of work after a physical rollback.
rollbackPhysically()  : void

Properties

$closedByRollbackOnly

The last commit rolled the transaction back, so a following rollback by the caller is a no-op.

private bool $closedByRollbackOnly = false

$rollbackOnly

A nested level rolled back; the outermost commit rolls back instead of committing.

private bool $rollbackOnly = false

Methods

__construct()

public __construct(EntityManagerInterface $entityManager) : mixed
Parameters
$entityManager : EntityManagerInterface

closeLeftoverTransaction()

Safety net at the end of a request (`Application::onShutdown`, web/Api/cron).

public closeLeftoverTransaction(mixed ...$shutdownArgs) : void

A transaction nobody closed (begin without commit or rollback on an error path) would otherwise vanish silently only on DB disconnect, and every later "standalone" transaction in the same process would nest into it. Logs it (channel transaction.leak) and rolls it back; committing unfinished work would be a gamble.

Parameters
$shutdownArgs : mixed

commit()

Counts levels: a nested commit only decrements. The real action happens at the outermost level: a commit, or a rollback when a nested level rolled back (an inner save failed). In that case {@see RollbackOnlyException} is thrown after the rollback so the caller does not report "saved" when nothing was saved.

public commit() : void

isRollbackOnly()

A nested level rolled back; the last commit rolls back.

public isRollbackOnly() : bool
Return values
bool

rollback()

Counts levels: a nested rollback only decrements and marks the transaction rollback-only.

public rollback() : void

Nothing is rolled back physically; the outer caller keeps working in the same transaction (its writes are not autocommitted) and its last commit or rollback undoes everything.

discardUnitOfWork()

Clears the whole unit of work after a physical rollback.

private discardUnitOfWork() : void

The outermost rollback is always complete (no savepoints): everything since begin is gone from the DB. In-memory entities (dirty root of a rejected save, replaced collections, scheduled orphan removals) would otherwise be written by the next flush in the same EM (next cron or import item, another manager). Entities held by the caller become detached: reload them, do not save them.

On this page

Search results