API15

JRegistryFormat/getInstance

< API15:JRegistryFormat

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Returns a reference to a Format 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($format)
Parameter Name Default Value Description
$format $format The format to load

Returns

object Registry format handler

Defined in

libraries/joomla/registry/format.php

Importing

jimport( 'joomla.registry.format' );

Source Body

function &getInstance($format)
{
        static $instances;

        if (!isset ($instances)) {
                $instances = array ();
        }

        $format = strtolower(JFilterInput::clean($format, 'word'));
        if (empty ($instances[$format]))
        {
                $class = 'JRegistryFormat'.$format;
                if(!class_exists($class))
                {
                        $path    = dirname(__FILE__).DS.'format'.DS.$format.'.php';
                        if (file_exists($path)) {
                                require_once($path);
                        } else {
                                JError::raiseError(500,JText::_('Unable to load format class'));
                        }
                }

                $instances[$format] = new $class ();
        }
        return $instances[$format];
}

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

Examples

Code Examples


Advertisement