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

The AMI_Registry class

• Introduction

Registry.

• Class synopsis

AMI_Registry {
/* Methods */
// Deletes key and returns value before deletion.
public static delete ( string $key ) returns mixed;
// Returns key existence.
public static exists ( string $key ) returns bool;
// Returns value by specified key.
public static get ( string $key, [ mixed $default = null ] ) returns mixed;
public set ( mixed $key, mixed $value ) returns void;
}

• Class Details

Since 7.0.0 version following data is available for reading.

Common context:
  • path/root - path to site root folder (string);
  • path/www_root - www path to site root folder (string);
  • path/hyper_local - path to local hypermodules/configurations folder;
  • path/images - path to front side images (string);
  • path/www_images - www path to front side images (string).
Since 5.12.0 version following data is available for reading.

Common context:
  • lang_data - data language (string).
Admin context:
  • lang - interface language (string).
Full front module context:
  • page/id - requested page id (from Site Manager, int);
  • page/modId - requested page module id (from Site Manager, string, 'page_404' if requested page not found);
  • page/itemId - item id (from requested module, string, '0' if no element was requested, '-1' if element sublink is wrong);
  • page/catId - item category id (from requested module, string, '0' if no category was requested, '-1' if category sublink is wrong);
  • page/isAvailable - front availability flag (bool);
  • page/seoData/index - robots meta 'index' (since 5.12.4);
  • page/seoData/follow - robots meta 'follow' (since 5.12.4).
Example:
  •  // Let our plugin is placed at all eshop catalog pages and we need to display a message for some products.
  •  // my_specblock.php
  •  $aProductIds array(123);
  •  $resultHtml '';
  •  if(
  •      AMI_Registry::get('page/isAvailable'&&
  •      AMI_Registry::get('page/modId'== 'eshop_item'&&
  •      in_array(AMI_Registry::get('page/itemId')$aProductIds)
  •  ){
  •      $resultHtml 'Extraordinary product';
  •  }

• Class Methods

// Deletes key and returns value before deletion.
public static delete ( string $key ) returns mixed;
  • string $key
    Key
// Returns key existence.
public static exists ( string $key ) returns bool;
  • string $key
    Key
// Returns value by specified key.
public static get ( string $key, [ mixed $default = null ] ) returns mixed;
  • string $key
    Key
  • mixed $default
    Default value, will be returned if there is no key in the registry
  Example:

  Example:
  •  AMI_Registry::set('options'array(
  •      'section1' => array(
  •           'key1' => 'value1',
  •           'key2' => 'value2'
  •      ),
  •      'section2' => array(
  •           'key1' => array(
  •               'k1' => 'v1',
  •               'k2' => 'v2'
  •           )
  •  ));
  •  ...
  •  $aSection1 AMI_Registry::get('options/section1'array());
  •  // $aSection1 == array(
  •  //     'key1' => 'value1',
  •  //     'key2' => 'value2'
  •  // )
  •  ...
  •  $k2 AMI_Registry::get('options/section2/key1/k2');
  •  // $k2 == 'v2'
  •  
  •  $k3 AMI_Registry::get('options/section2/key1/k3''k3DefaultValue');
  •  // $k3 == 'k3DefaultValue'
public set ( mixed $key, mixed $value ) returns void;