Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

The AMI_Tx class

• Introduction

Transaction abstraction.

• Class synopsis

AMI_Tx implements AMI_iTx {
/* Properties */
// Variable containing current transactions state, using for offline rollback.
protected static array $aState;
// Variable containing global transactions state, using for offline rollback.
protected static int $stateIndex = 0;
// Array of backup data needed for revert
protected array $aBackup = array();
// Array of supported commands, must be filled in children
protected array $aCmdResources = array();
// Array of commands
protected array $aCmds = array();
// Array of executing commands
protected array $aExecutingCmds = array();
// Array of entities existence flags
protected array $aExistence = array();
// Array of precommited commands
protected array $aPrecommitedCmds = array();
// Precommited commands count
protected int $cmdsCount = 0;
// Failed commit command index in AMI_Tx::$aPrecommitedCmds
protected int $index;
// Variable containing current transactions state, using for offline rollback.
protected int $localStateIndex;
// Contains exception fired on commit
// Flag specifying is transaction started
protected bool $started = FALSE;
// State file path
protected string $statePath;
/* Methods */
// Logs message to "_admin/_logs/tx.log".
public static log ( string $message, [ int $type = self::LOG_NOTE ] ) returns void;
// Add command executed on commit.
public addCommand ( string $cmd, [ mixed $data = null ] ) returns void;
// Adds command resources.
public addCommandResources ( $aResources ) returns void;
// Commit tracnsaction.
public commit ( ) returns void;
// Returns backup entity name or null.
public getBackupName ( string $entity, [ $oStorage = null ] ) returns string|null;
// Returns TRUE if transaction is started but not commited.
public isStarted ( ) returns bool;
// Rollback tracnsaction.
public rollback ( ) returns void;
// Set backup entity name.
public setBackupName ( string $entity, string $name, [ $oStorage = null ] ) returns void;
// Set backup entity name.
public setExistence ( string $entity, bool $exists, [ $oStorage = null ] ) returns void;
// Start transaction.
public start ( strung $name ) returns void;
// Output message.
protected output ( string $message, [ bool $output = TRUE ], [ int $type = self::LOG_NOTE ] ) returns void;
// Create and store all tracnsaction commands.
protected precommit ( ) returns void;
// Update file containing state fr possible offline rollback.
protected updateState ( ) returns void;
}
Tags:
abstract
since 6.0.2

• Class Properies

protected static array $aState

Variable containing current transactions state, using for offline rollback.

protected static int $stateIndex

Variable containing global transactions state, using for offline rollback.

protected array $aBackup

Array of backup data needed for revert

protected array $aCmdResources

Array of supported commands, must be filled in children

Example:

  •  protected $aCmdResources array(
  •      // command        // resource
  •      'storage/copy' => 'tx/cmd/storage/copy'
  •  );

protected array $aCmds

Array of commands

protected array $aExecutingCmds

Array of executing commands

Used for adding command during execution

protected array $aExistence

Array of entities existence flags

protected array $aPrecommitedCmds

Array of precommited commands

protected int $cmdsCount

Precommited commands count

protected int $index

Failed commit command index in AMI_Tx::$aPrecommitedCmds

protected int $localStateIndex

Variable containing current transactions state, using for offline rollback.

protected AMI_Tx_Exception $oCommitException

Contains exception fired on commit

protected bool $started

Flag specifying is transaction started

protected string $statePath

State file path

• Class Methods

// Logs message to "_admin/_logs/tx.log".
public static log ( string $message, [ int $type = self::LOG_NOTE ] ) returns void;
  • string $message
    Message
  • int $type
    Type: self::LOG_NOTE / self::LOG_WARN / self::LOG_ERR

Implementation of: AMI_iTx::log().

// Add command executed on commit.
public addCommand ( string $cmd, [ mixed $data = null ] ) returns void;
  • string $cmd
    ommand
  • mixed $data
    Command data

Implementation of: AMI_iTx::addCommand().

// Adds command resources.
public addCommandResources ( $aResources ) returns void;
  • array $aResources
    Resources
// Commit tracnsaction.
public commit ( ) returns void;

Implementation of: AMI_iTx::commit().

// Returns backup entity name or null.
public getBackupName ( string $entity, [ $oStorage = null ] ) returns string|null;
  • string $entity
    Entity (file name, db table name, etc.)
  • AMI_iStorage $oStorage
    Storage object

Implementation of: AMI_iTx::getBackupName().

// Returns TRUE if transaction is started but not commited.
public isStarted ( ) returns bool;

Implementation of: AMI_iTx::isStarted().

// Rollback tracnsaction.
public rollback ( ) returns void;

Implementation of: AMI_iTx::rollback().

// Set backup entity name.
public setBackupName ( string $entity, string $name, [ $oStorage = null ] ) returns void;
  • string $entity
    Entity (file name, db table name, etc.)
  • string $name
    Backup entity name
  • AMI_iStorage $oStorage
    Storage object

Implementation of: AMI_iTx::setBackupName().

// Set backup entity name.
public setExistence ( string $entity, bool $exists, [ $oStorage = null ] ) returns void;
  • string $entity
    Entity (file name, db table name, etc.)
  • bool $exists
    Flag specifying existence
  • AMI_iStorage $oStorage
    Storage object

Implementation of: AMI_iTx::setExistence().

// Start transaction.
public start ( strung $name ) returns void;
  • strung $name
    Transaction name

Implementation of: AMI_iTx::start().

// Output message.
protected output ( string $message, [ bool $output = TRUE ], [ int $type = self::LOG_NOTE ] ) returns void;
  • string $message
    Message
  • bool $output
    Do output
  • int $type
    Type: self::LOG_NOTE / self::LOG_WARN / self::LOG_ERR
// Create and store all tracnsaction commands.
protected precommit ( ) returns void;
// Update file containing state fr possible offline rollback.
protected updateState ( ) returns void;