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

The AMI_Tx_Cmd_Package_HandlersInstaller class

AMI_Tx_Cmd
   |
   --AMI_Tx_Cmd_Storage
      |
      --AMI_Tx_Cmd_Storage_ContentModifier
         |
         --AMI_Tx_Cmd_PHP_ContentModifier
            |
            --AMI_Tx_Cmd_PHP_ContentIntsall
               |
               --AMI_Tx_Cmd_Package_HandlersInstaller

• Introduction

Event handlers installation transaction command.

• Class synopsis

AMI_Tx_Cmd_Package_HandlersInstaller extends AMI_Tx_Cmd_PHP_ContentIntsall {
/* Properties */
// Obligatory arguments.
protected array $aObligatoryArgs = array('handlerRegistrationSource', 'handlerDeclarationSource');
// Handler declaration closing marker
protected string $handlerDeclarationCloser;
// Handler declaration opening marker
protected string $handlerDeclarationOpener;
// Handler registration closing marker
protected string $handlerRegistrationCloser;
// Handler registration opening marker
protected string $handlerRegistrationOpener;
/* Inherited Properties */
// Flag specifies if previous file was backuped
protected AMI_Tx_Cmd_Storage::$backuped = FALSE;
// Path for backup file
// EOL style for conent modifiers
protected AMI_Tx_Cmd_Storage::$eol = "\r\n";
// Storage driver
// Backup name
// Command arguments
protected AMI_Tx_Cmd::$oArgs;
// Current transaction object
protected AMI_Tx_Cmd::$oTx;
// Flag specifying to replace original file on commit
protected AMI_Tx_Cmd::$replaceOnCommit = TRUE;
/* Methods */
// Creates new if no content present.
protected createNewContent ( ) returns string;
// Initializes command.
protected init ( ) returns void;
// Runs command.
protected run ( ) returns void;
// Validates passed arguments.
protected validateArgs ( ) returns void;
/* Inherited Methods */
// Callback filterring objects from arguments.
protected AMI_Tx_Cmd_PHP_ContentIntsall::cbFilterObjects ( mixed $value ) returns bool;
// Callback converting key to template variable name.
protected AMI_Tx_Cmd_PHP_ContentIntsall::cbToTplVar ( string $key ) returns string;
// Initializes command.
protected AMI_Tx_Cmd_PHP_ContentIntsall::init ( ) returns void;
// Content modifier.
protected AMI_Tx_Cmd_PHP_ContentIntsall::modify ( string &$content, string $opener, string $closer ) returns void;
// Validates passed arguments.
protected AMI_Tx_Cmd_PHP_ContentIntsall::validateArgs ( ) returns void;
// Creates new if no content present.
protected AMI_Tx_Cmd_PHP_ContentModifier::createNewContent ( ) returns string;
// Returns closing marker.
protected AMI_Tx_Cmd_PHP_ContentModifier::getClosingMarker ( ) returns string;
// Returns opening marker.
protected AMI_Tx_Cmd_PHP_ContentModifier::getOpeningMarker ( ) returns string;
// Add/replace markers.
protected AMI_Tx_Cmd_Storage_ContentModifier::checkMarkers ( string &$content, string $opener, string $closer ) returns bool;
// Creates new if no content present.
// Returns closing marker.
// Returns opening marker.
// Content modifier.
protected AMI_Tx_Cmd_Storage_ContentModifier::modify ( string &$content, string $opener, string $closer ) returns void;
// Runs command.
protected AMI_Tx_Cmd_Storage_ContentModifier::run ( ) returns void;
// Validates passed arguments.
// Adds resources of available commands.
public static AMI_Tx_Cmd_Storage::addResources ( ) returns void;
// Commits command.
public AMI_Tx_Cmd_Storage::commit ( ) returns void;
// Rollbacks command.
public AMI_Tx_Cmd_Storage::rollback ( ) returns void;
// Backups target file.
protected AMI_Tx_Cmd_Storage::backup ( ) returns void;
// Copies source to target file.
protected AMI_Tx_Cmd_Storage::copy ( ) returns void;
// Initializes command.
protected AMI_Tx_Cmd_Storage::init ( ) returns void;
// Sets target file content.
protected AMI_Tx_Cmd_Storage::set ( [ string $content = null ] ) returns void;
// Validates passed arguments.
protected AMI_Tx_Cmd_Storage::validateArgs ( ) returns void;
// Constructor.
public AMI_Tx_Cmd::__construct ( $oTx, AMI_Tx_Cmd_Args $oArgs ) returns AMI_Tx_Cmd;
// Returns string containing argements for logging.
public AMI_Tx_Cmd::getLoggingArgs ( ) returns string;
// Returns string containing specifying arguments and values.
protected AMI_Tx_Cmd::argsToString ( [ $aArgs = array() ] ) returns string;
// Initializes command.
protected AMI_Tx_Cmd::init ( ) returns void;
// Runs command.
protected AMI_Tx_Cmd::run ( ) returns void;
// Validates passed arguments.
protected AMI_Tx_Cmd::validateArgs ( ) returns void;
// Validates obligatory arguments.
protected AMI_Tx_Cmd::validateObligatoryArgs ( $aArgs ) returns void;
}

• Class Details

  Example:
  •  // "install_after.php" / "install.php" context
  •  
  •  $srcPath = dirname(__FILE__) . '/';
  •  $destPath = AMI_Registry::get('path/root') . '_local/';
  •  
  •  $oStorage = AMI::getResource('storage/fs');
  •  
  •  $file = 'common_functions.php';
  •  $oArgs = new AMI_Tx_Cmd_Args(
  •      array(
  •          // Package Id
  •          'pkgId'    => $this->oArgs->pkgId,
  •          // Hypermodule
  •          'hypermod' => $this->oArgs->hypermod,
  •          // Configuration
  •          'config'   => $this->oArgs->config,
  •          // Instance Id
  •          'modId'    => $this->oArgs->modId,
  •          // Installation mode
  •          'mode'     => $this->oArgs->mode,
  •          // Source PHP-file path
  •          'handlerRegistrationSource' => $srcPath . 'commonEventHandlersRegistration.php',
  •          // Source PHP-file path
  •          'handlerDeclarationSource'  => $srcPath . 'commonEventHandlersDeclaration.php',
  •          // Target PHP-file to patch
  •          'target'   => $destPath . $file,
  •          // Storage driver
  •          'oStorage' => $oStorage
  •      )
  •  );
  •  $this->aTx['storage']->addCommand('pkg/handlers/install', $oArgs);
  •  
  •  // File 'commonEventHandlersRegistration.php' contains PHP-template:
  •  <?php
  •  ....
  •  // {{}}  <- PHP-code template start marker
  •  AMI_Event::addHandler('...''amiHandler'...);
  •  ...
  •  
  •  // File 'commonEventHandlersDeclaration.php' contains PHP-template:
  •  <?php
  •  ....
  •  // {{}}  <- PHP-code template start marker
  •  function amiHandler($namearray $aEvent$handlerModId$srcModId){
  •      ...
  •  }
  •  ...
Tags:
resource tx/cmd/pkg/handlers/install AMI::getResource('tx/cmd/pkg/handlers/install')
since 6.0.6

• Class Properies

protected array $aObligatoryArgs

Obligatory arguments.

protected string $handlerDeclarationCloser

Handler declaration closing marker

protected string $handlerDeclarationOpener

Handler declaration opening marker

protected string $handlerRegistrationCloser

Handler registration closing marker

protected string $handlerRegistrationOpener

Handler registration opening marker

• Class Methods

// Creates new if no content present.
protected createNewContent ( ) returns string;
// Initializes command.
protected init ( ) returns void;
// Runs command.
protected run ( ) returns void;

Overrides: AMI_Tx_Cmd_Storage_ContentModifier::run().

Patches target file.
Tags:
throws AMI_Tx_Exception In case of missing obligatory argument.
// Validates passed arguments.
protected validateArgs ( ) returns void;

Overrides: AMI_Tx_Cmd_PHP_ContentIntsall::validateArgs().

Tags:
see AMI_Cmd::__construct()