JApplication/ construct: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Class constructor.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</... |
m clean up |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
Class constructor. | Class constructor. | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
Line 29: | Line 27: | ||
===Source Body=== | ===Source Body=== | ||
<source lang="php"> | <source lang="php"> | ||
function __construct($config = array()) | |||
{ | { | ||
jimport('joomla.utilities.utility'); | jimport('joomla.utilities.utility'); | ||
// | //set the view name | ||
$this->_name = $this->getName(); | $this->_name = $this->getName(); | ||
$this->_clientId = $config['clientId']; | $this->_clientId = $config['clientId']; | ||
// Enable sessions by default | //Enable sessions by default | ||
if (!isset($config['session'])) { | if(!isset($config['session'])) { | ||
$config['session'] = true; | $config['session'] = true; | ||
} | } | ||
// Set the session default name | //Set the session default name | ||
if (!isset($config['session_name'])) { | if(!isset($config['session_name'])) { | ||
$config['session_name'] = $this->_name; | $config['session_name'] = $this->_name; | ||
} | } | ||
// Set the default configuration file | //Set the default configuration file | ||
if (!isset($config['config_file'])) { | if(!isset($config['config_file'])) { | ||
$config['config_file'] = 'configuration.php'; | $config['config_file'] = 'configuration.php'; | ||
} | } | ||
// | //create the configuration object | ||
$this->_createConfiguration(JPATH_CONFIGURATION.DS.$config['config_file']); | $this->_createConfiguration(JPATH_CONFIGURATION.DS.$config['config_file']); | ||
// | //create the session if a session name is passed | ||
if ($config['session'] !== false) { | if($config['session'] !== false) { | ||
$this->_createSession(JUtility::getHash($config['session_name'])); | $this->_createSession(JUtility::getHash($config['session_name'])); | ||
} | } | ||
$this->set('requestTime', gmdate('Y-m-d H:i' | $this->set( 'requestTime', gmdate('Y-m-d H:i') ); | ||
} | } | ||
</source> | </source> | ||
<! removed transcluded page call, red link never existed > | |||
< | |||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=__construct | category=__construct | ||
category=JApplication | category=JApplication | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API15]] |
Latest revision as of 00:14, 25 March 2017
Description
Class constructor.
<! removed transcluded page call, red link never existed >
Syntax
__construct($config=array())
Parameter Name | Default Value | Description |
---|---|---|
$config | array() | A client identifier. |
Defined in
libraries/joomla/application/application.php
Importing
jimport( 'joomla.application.application' );
Source Body
function __construct($config = array())
{
jimport('joomla.utilities.utility');
//set the view name
$this->_name = $this->getName();
$this->_clientId = $config['clientId'];
//Enable sessions by default
if(!isset($config['session'])) {
$config['session'] = true;
}
//Set the session default name
if(!isset($config['session_name'])) {
$config['session_name'] = $this->_name;
}
//Set the default configuration file
if(!isset($config['config_file'])) {
$config['config_file'] = 'configuration.php';
}
//create the configuration object
$this->_createConfiguration(JPATH_CONFIGURATION.DS.$config['config_file']);
//create the session if a session name is passed
if($config['session'] !== false) {
$this->_createSession(JUtility::getHash($config['session_name']));
}
$this->set( 'requestTime', gmdate('Y-m-d H:i') );
}
<! removed transcluded page call, red link never existed >
Examples
Code Examples