API16:JRegistry/getInstance
From Joomla! Documentation
Description
Returns a reference to a global JRegistry object, only creating it if it doesn't already exist.
Syntax
static getInstance($id, $namespace= '_default')
| Parameter Name | Default Value | Description |
|---|---|---|
| $id | An ID for the registry instance | |
| $namespace | '_default' | The default namespace for the registry object [optional] |
Returns
object The object.
Defined in
libraries/joomla/registry/registry.php
Importing
jimport( 'joomla.registry.registry' );
Source Body
public static function getInstance($id, $namespace = '_default')
{
static $instances;
if (!isset ($instances)) {
$instances = array ();
}
if (empty ($instances[$id])) {
$instances[$id] = new JRegistry($namespace);
}
return $instances[$id];
}
Examples
Code Examples