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

The AMI_Package_Install class

AMI_Package_Manipulator
   |
   --AMI_Package_InstanceManipulator
      |
      --AMI_Package_Install

• Introduction

Transaction installing CMS package.

• Class synopsis

AMI_Package_Install extends AMI_Package_InstanceManipulator {
/* Properties */
// Module captions
protected array $aCaptions;
// Audit status for successfull transaction
protected string $auditSuccessStatus = 'added';
// Package install Id
protected int $installId;
// Transaction type for audit
protected string $transactionType = 'install';
/* Inherited Properties */
// Processed module Ids
// Package info
// Flag specifying hypermodule/config is single instanced
// Module Id
// Package Id
// Hypermodule/config for single instanced or module Id
// Module section
// Module tab order
// Array containing class methods to run
protected AMI_Package_Manipulator::$aActions = array();
// Array of transactions
protected AMI_Package_Manipulator::$aTx = array();
// Used to store previous exception
// Name for transactions, must be filled in children
/* Methods */
// Constructor.
public __construct ( string $pkgId, string $section, int $taborder, string $modId, $aCaptions, [ int $mode = AMI_iTx_Cmd::MODE_COMMON ] ) returns AMI_Package_Install;
// Returns module Id.
public getModId ( ) returns string;
// Transaction action.
protected installInstances ( ) returns void;
// Transaction action.
protected logFinish ( ) returns void;
// Transaction action.
protected logStart ( ) returns void;
// Transaction action.
protected validateModes ( ) returns void;
/* Inherited Methods */
// Resource list filter callback.
protected AMI_Package_InstanceManipulator::cbFilterResourceList ( string $file ) returns bool;
// Transaction action.
// Returns config resource content.
protected AMI_Package_InstanceManipulator::getContentByResource ( string $resource ) returns string;
// Returns resources by type.
protected AMI_Package_InstanceManipulator::getResources ( string $type ) returns array;
// Initialization.
protected AMI_Package_InstanceManipulator::init ( ) returns void;
// Returns TRUE if hypermodule/config specifies meta has according property.
// Validates initial data.
protected AMI_Package_InstanceManipulator::validate ( ) returns void;
// Do actions.
public AMI_Package_Manipulator::doActions ( ) returns void;
// Runs transactions.
public AMI_Package_Manipulator::run ( ) returns void;
// Adds action.
protected AMI_Package_Manipulator::addAction ( string $method, [ $aArgs = null ] ) returns void;
// Commits transactions.
protected AMI_Package_Manipulator::commit ( ) returns void;
// Converts mode to string representation for logging.
protected AMI_Package_Manipulator::getModeAsString ( int $mode ) returns string;
// Initializes transactions.
protected AMI_Package_Manipulator::initTx ( ) returns void;
// Rollbacks transactions.
protected AMI_Package_Manipulator::rollback ( [ int $index = 0 ] ) returns void;
// Validates initial data.
protected AMI_Package_Manipulator::validate ( ) returns void;
}

• Class Details

  Example:
  •  // Root script context
  •  
  •  $AMI_ENV_SETTINGS array(
  •      'mode'          => 'full',
  •      'disable_cache' => TRUE
  •  );
  •  require_once 'ami_env.php';
  •  
  •  $oResponse AMI::getSingleton('response');
  •  $oResponse->start();
  •  
  •  $pkgId     'amiro.sample';
  •  $section   'plugins';
  •  $taborder  0;
  •  $modId     'inst_ami_sample'
  •  $aCaptions array(
  •      'en' => array(
  •          '' => array(
  •              'header'           => 'SAMPLE MODULE',
  •              'menu'             => 'Sample Module',
  •              'description'      => 'Sample instance of AmiClean base hypermodule / AmieSample configuration',
  •              'specblock'        => 'First specblock',
  •              'specblock:custom' => 'Second specblock'
  •          )
  •      ),
  •      'ru' => array(
  •          '' => array(
  •              'header'           => 'SAMPLE MODULE (ru)',
  •              'menu'             => 'Sample Module (ru)',
  •              'description'      => 'Sample instance of AmiClean base hypermodule / AmieSample configuration (ru)',
  •              'specblock'        => 'First specblock (ru)',
  •              'specblock:custom' => 'Second specblock (ru)'
  •          )
  •      )
  •  );
  •  
  •  $oModManipulator new AMI_PackageInstall(
  •      $pkgId,
  •      $section,
  •      $taborder,
  •      $modId,
  •      $aCaptions,
  •      AMI_iTx_Cmd::MODE_COMMON
  •  );
  •  try{
  •      $oModManipulator->run();
  •      // Success installation
  •      // ...
  •  }catch(AMI_Exception $oException){
  •      // Installation failed
  •      d::w('<span style="color: red;">' $oException->getMessage('</span>');
  •      d::trace($oException->getTrace());
  •  }
  •  
  •  $oResponse->send();
Tags:
since 6.0.2

• Class Properies

protected array $aCaptions

Module captions

protected string $auditSuccessStatus

Audit status for successfull transaction

protected int $installId

Package install Id

protected string $transactionType

Transaction type for audit

• Class Methods

// Constructor.
public __construct ( string $pkgId, string $section, int $taborder, string $modId, $aCaptions, [ int $mode = AMI_iTx_Cmd::MODE_COMMON ] ) returns AMI_Package_Install;
  • string $pkgId
    Package Id
  • string $section
    Admin section
  • int $taborder
    Module tab order
  • string $modId
    Module Id, if not started with 'inst_' will be prefixed
  • array $aCaptions
    FIrst configuration captions
  • int $mode
    Flags specifying installation mode, AMI_iTx_Cmd::MODE_*
// Returns module Id.
public getModId ( ) returns string;
// Transaction action.
protected installInstances ( ) returns void;
Install instances from package.
Tags:
throws AMI_Tx_Exception In case of problems.
// Transaction action.
protected logFinish ( ) returns void;
Update state in record of mod manager history table.
Tags:
throws AMI_Tx_Exception In case of problems.
// Transaction action.
protected logStart ( ) returns void;
Create record in mod manager history table.
// Transaction action.
protected validateModes ( ) returns void;
Validates install/uninstall modes from meta.