Difference between revisions of "JApplication/getInstance"
From Joomla! Documentation
< API16:JApplication
(New page: ===Description===
Returns the global JApplication object, only creating it if it doesn't already exist.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Descripti...) |
m (removing red link to edit, no existant pages) |
||
Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 77: | Line 77: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
Line 92: | Line 92: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API16]] |
Revision as of 20:57, 12 May 2013
The "API16" 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[edit]
Returns the global JApplication 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[edit]
static getInstance($client, $config=array(), $prefix= 'J')
Parameter Name | Default Value | Description |
---|---|---|
$client | A client identifier or name. | |
$config | array() | An optional associative array of configuration settings. |
$prefix | 'J' |
Returns[edit]
The appliction object.
Defined in[edit]
libraries/joomla/application/application.php
Importing[edit]
jimport( 'joomla.application.application' );
Source Body[edit]
public static function getInstance($client, $config = array(), $prefix = 'J')
{
static $instances;
if (!isset($instances)) {
$instances = array();
}
if (empty($instances[$client]))
{
// Load the router object.
jimport('joomla.application.helper');
$info = &JApplicationHelper::getClientInfo($client, true);
$path = $info->path.DS.'includes'.DS.'application.php';
if (file_exists($path))
{
require_once $path;
// Create a JRouter object.
$classname = $prefix.ucfirst($client);
$instance = new $classname($config);
}
else
{
$error = JError::raiseError(500, 'Unable to load application: '.$client);
return $error;
}
$instances[$client] = &$instance;
}
return $instances[$client];
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />