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

The AMI_Service class

• Introduction

AMI service class.

• Class synopsis

AMI_Service {
/* Constants */
const AMI_Service::LOG_ERR =  3;
const AMI_Service::LOG_NOTE =  1;
const AMI_Service::LOG_WARN =  2;
/* Methods */
// Adds collation between class name and its file name for class autoloading.
public static addClassMapping ( $aMapping ) returns void;
// Manages debug output by GET parameter.
public static debugByRequest ( string $requestName ) returns void;
// Returns CMS version.
public static getVersion ( ) returns array;
// Logs message.
public static log ( string $message, [ string $path = '' ], [ int $maxLogSize = self::DEFAULT_MAX_LOG_SIZE ] ) returns void;
// User defined handlers.
public addAutoloadPath ( mixed $path ) returns void;
// Initializes user defined handlers.
public _getScopeVariable ( $aMatches, string $type ) returns void;
}

• Class Details

Provides autoload and class mapping functionality.
Tags:
since 5.10.0

• Class Constants

LOG_ERR
LOG_NOTE
LOG_WARN

• Class Methods

// Adds collation between class name and its file name for class autoloading.
public static addClassMapping ( $aMapping ) returns void;
  • array $aMapping
    Mapping
  Example:
  •  // Let our file "_local/plugins_distr/my_plugin/code/Foo.php" contains three classes:
  •  class Foo1{
  •      // ...
  •  }
  •  
  •  class Foo2{
  •      // ...
  •  }
  •  
  •  class Foo3{
  •      // ...
  •  }
  •  
  •  // and we need to autoload these classes from other file "_local/plugins_distr/my_plugin/code/file.php".
  •  // Than we should write next code:
  •  AMI_Service::addAutoloadPath('_local/plugins_distr/my_plugin/code/');
  •      'Foo1' => 'Foo',
  •      'Foo2' => 'Foo',
  •      'Foo3' => 'Foo'
  •  ));
  •  // After setting class mapping we can write
  •  $oObject1 new Foo1();
  •  $oObject1 new Foo2();
  •  $oObject1 new Foo3();
  •  // instead of
  •  require_once 'Foo.php'
  •  $oObject1 new Foo1;
  •  require_once 'Foo.php'
  •  $oObject2 new Foo2;
  •  require_once 'Foo.php'
  •  $oObject3 new Foo3;
// Manages debug output by GET parameter.
public static debugByRequest ( string $requestName ) returns void;
  • string $requestName
    GET parameter name
Useful when you have shared IP address and need to hide debug from site visitors having the same IP address.
You can add example code to the file "_local/common_functions.php" replacing 'debug' by yor own GET parameter.

  Example:
 http://cms.my/?debug=on - turn on bebug output
 http://cms.my/?debug=off - turn off bebug output
// Returns CMS version.
public static getVersion ( ) returns array;
Tags:
since 6.0.2
// Logs message.
public static log ( string $message, [ string $path = '' ], [ int $maxLogSize = self::DEFAULT_MAX_LOG_SIZE ] ) returns void;
  • string $message
    Message
  • string $path
    Path to log file
  • int $maxLogSize
    Max log file size, used for rotation
// User defined handlers.
public addAutoloadPath ( mixed $path ) returns void;
// Initializes user defined handlers.
public _getScopeVariable ( $aMatches, string $type ) returns void;
  • string $type
    Handlers type, 'common' | 'admin' | 'front'