API15

Difference between revisions of "JApplication/ construct"

From Joomla! Documentation

< API15:JApplication
(New page: ===Description=== Class constructor. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </...)
 
Line 29: Line 29:
 
===Source Body===
 
===Source Body===
 
<source lang="php">
 
<source lang="php">
public function __construct($config = array())
+
function __construct($config = array())
 
{
 
{
 
         jimport('joomla.utilities.utility');
 
         jimport('joomla.utilities.utility');
        jimport('joomla.error.profiler');
 
  
         // Set the view name.
+
         //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.
+
         //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.
+
         //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') );
 
 
        // Used by task system to ensure that the system doesn't go over time.
 
        $this->set('startTime', JProfiler::getmicrotime());
 
 
}
 
}
 
</source>
 
</source>

Revision as of 17:08, 22 March 2010

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[edit]

Class constructor.

[Edit Descripton]

Template:Description:JApplication/ construct

Syntax[edit]

__construct($config=array())
Parameter Name Default Value Description
$config array() A client identifier.

Defined in[edit]

libraries/joomla/application/application.php

Importing[edit]

jimport( 'joomla.application.application' );

Source Body[edit]

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') );
}

[Edit See Also] Template:SeeAlso:JApplication/ construct

Examples[edit]

<CodeExamplesForm />