Actions

API15

JRegistry/getInstance

From Joomla! Documentation

< API15:JRegistry
Revision as of 13:43, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Returns a reference to a global JRegistry object, only creating it if it doesn't already exist.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

& getInstance($id, $namespace= 'default')
Parameter Name Default Value Description
$id $id An ID for the registry instance
$namespace 'default' $namespace 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

function &getInstance($id, $namespace = 'default')
{
        static $instances;
 
        if (!isset ($instances)) {
                $instances = array ();
        }
 
        if (empty ($instances[$id])) {
                $instances[$id] = new JRegistry($namespace);
        }
 
        return $instances[$id];
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />