Permalink
Browse files

Merge branch 'master' of github.com:joomla/joomla-platform into files…

…ystem
  • Loading branch information...
2 parents dd67421 + 86b76c2 commit 0c920a295836111e2b753fb3997e855ac6173442 @chdemko committed Mar 29, 2012
@@ -20,8 +20,7 @@
<para>For files that contain only PHP code, the closing tag (?&gt;) should not be included. It is not required by PHP.
Leaving this out prevents trailing white space from being accidentally injected into the output that can introduce errors in
- the Joomla session (see the PHP manual on instruction separation at
- http://php.net/basic-syntax.instruction-separation).</para>
+ the Joomla session (see the PHP manual on <ulink url="http://php.net/basic-syntax.instruction-separation">Instruction separation</ulink>.</para>
<para>Files should always end with a blank new line.</para>
@@ -646,7 +645,7 @@ class JClass extends JObject
<para>Exceptions should be used for error handling.</para>
- <para>The follow sections outline how to semantically use SPL exceptions</para>
+ <para>The follow sections outline how to semantically use <ulink url="http://php.net/manual/en/spl.exceptions.php">SPL exceptions</ulink>.</para>
<section>
<title>Logic Exceptions</title>
@@ -655,7 +654,7 @@ class JClass extends JObject
being used. For example:</para>
<simplelist>
- <member>A dependancy has failed (you try to operate on an object that has not been loaded yet).</member>
+ <member>A dependency has failed (you try to operate on an object that has not been loaded yet).</member>
</simplelist>
<para>The following child classes can also be used in appropriate situations.</para>
@@ -679,8 +678,7 @@ class JClass extends JObject
<simplelist>
<member><methodname>is_callable</methodname>, or similar, fails on a class method.</member>
-
- <member>There where missing arguments passed to a magic call method.</member>
+ <member>Arguments passed to a magic call method are missing.</member>
</simplelist>
</section>
@@ -723,7 +721,7 @@ class JClass extends JObject
<para>The <exceptionname>RuntimeException</exceptionname> is thrown when some sort of external entity or environment causes
a problem that is beyond your control providing the input is valid. This exception is the default case for when the cause of
- an error can't explicity be determined. For example:</para>
+ an error can't explicitly be determined. For example:</para>
<simplelist>
<member>Tried to connect to a database but the database was not available (server down, etc).</member>
@@ -734,7 +732,7 @@ class JClass extends JObject
<section>
<title>UnexpectedValueException</title>
- <para>This type of exception should be used when an unecpected result is encountered. For example:</para>
+ <para>This type of exception should be used when an unexpected result is encountered. For example:</para>
<simplelist>
<member>A function call returned a string when a boolean was expected.</member>
@@ -21,20 +21,28 @@
abstract class JApplicationBase extends JObject
{
/**
- * The application input object.
+ * The application dispatcher object.
*
- * @var JInput
+ * @var JDispatcher
* @since 12.1
*/
- public $input = null;
+ protected $dispatcher;
/**
- * The application dispatcher object.
+ * The application identity object.
*
- * @var JDispatcher
+ * @var JUser
* @since 12.1
*/
- protected $dispatcher;
+ protected $identity;
+
+ /**
+ * The application input object.
+ *
+ * @var JInput
+ * @since 12.1
+ */
+ public $input = null;
/**
* Method to close the application.
@@ -43,6 +51,7 @@
*
* @return void
*
+ * @codeCoverageIgnore
* @since 12.1
*/
public function close($code = 0)
@@ -91,16 +100,42 @@ public function triggerEvent($event, array $args = null)
}
/**
- * Method to create an event dispatcher for the application. The logic and options for creating
- * this object are adequately generic for default cases but for many applications it will make
- * sense to override this method and create event dispatchers based on more specific needs.
+ * Allows the application to load a custom or default dispatcher.
*
- * @return void
+ * The logic and options for creating this object are adequately generic for default cases
+ * but for many applications it will make sense to override this method and create event
+ * dispatchers, if required, based on more specific needs.
+ *
+ * @param JDispatcher $dispatcher An optional dispatcher object. If omitted, the factory dispatcher is created.
+ *
+ * @return JApplicationBase This method is chainable.
*
* @since 12.1
*/
- protected function loadDispatcher()
+ public function loadDispatcher(JDispatcher $dispatcher = null)
{
- $this->dispatcher = JDispatcher::getInstance();
+ $this->dispatcher = ($dispatcher === null) ? JDispatcher::getInstance() : $dispatcher;
+
+ return $this;
+ }
+
+ /**
+ * Allows the application to load a custom or default identity.
+ *
+ * The logic and options for creating this object are adequately generic for default cases
+ * but for many applications it will make sense to override this method and create an identity,
+ * if required, based on more specific needs.
+ *
+ * @param JUser $identity An optional identity object. If omitted, the factory user is created.
+ *
+ * @return JApplicationBase This method is chainable.
+ *
+ * @since 12.1
+ */
+ public function loadIdentity(JUser $identity = null)
+ {
+ $this->identity = ($identity === null) ? JFactory::getUser() : $identity;
+
+ return $this;
}
}
@@ -82,16 +82,7 @@ public function __construct(JInputCli $input = null, JRegistry $config = null, J
$this->config = new JRegistry;
}
- // If a dispatcher object is given use it.
- if ($dispatcher instanceof JDispatcher)
- {
- $this->dispatcher = $dispatcher;
- }
- // Create the dispatcher based on the application logic.
- else
- {
- $this->loadDispatcher();
- }
+ $this->loadDispatcher($dispatcher);
// Load the configuration object.
$this->loadConfiguration($this->fetchConfigurationData());
@@ -201,6 +201,7 @@ public static function getInstance($name = null)
*
* @return JApplicationWeb Instance of $this to allow chaining.
*
+ * @deprecated 13.1
* @see loadSession()
* @see loadDocument()
* @see loadLanguage()
@@ -209,64 +210,25 @@ public static function getInstance($name = null)
*/
public function initialise($session = null, $document = null, $language = null, $dispatcher = null)
{
- // If a session object is given use it.
- if ($session instanceof JSession)
- {
- $this->session = $session;
- }
- // We don't have a session, nor do we want one.
- elseif ($session === false)
- {
- // Do nothing.
- }
// Create the session based on the application logic.
- else
+ if ($session !== false)
{
- $this->loadSession();
+ $this->loadSession($session);
}
- // If a document object is given use it.
- if ($document instanceof JDocument)
- {
- $this->document = $document;
- }
- // We don't have a document, nor do we want one.
- elseif ($document === false)
- {
- // Do nothing.
- }
// Create the document based on the application logic.
- else
+ if ($document !== false)
{
- $this->loadDocument();
+ $this->loadDocument($document);
}
- // If a language object is given use it.
- if ($language instanceof JLanguage)
- {
- $this->language = $language;
- }
- // We don't have a language, nor do we want one.
- elseif ($language === false)
- {
- // Do nothing.
- }
// Create the language based on the application logic.
- else
+ if ($language !== false)
{
- $this->loadLanguage();
+ $this->loadLanguage($language);
}
- // If a dispatcher object is given use it.
- if ($dispatcher instanceof JDispatcher)
- {
- $this->dispatcher = $dispatcher;
- }
- // Create the dispatcher based on the application logic.
- else
- {
- $this->loadDispatcher();
- }
+ $this->loadDispatcher($dispatcher);
return $this;
}
@@ -1003,44 +965,67 @@ protected function header($string, $replace = true, $code = null)
}
/**
- * Method to create a document for the Web application. The logic and options for creating this
- * object are adequately generic for default cases but for many applications it will make sense
- * to override this method and create document objects based on more specific needs.
+ * Allows the application to load a custom or default document.
*
- * @return void
+ * The logic and options for creating this object are adequately generic for default cases
+ * but for many applications it will make sense to override this method and create a document,
+ * if required, based on more specific needs.
+ *
+ * @param JDocument $document An optional document object. If omitted, the factory document is created.
+ *
+ * @return JApplicationWeb This method is chainable.
*
* @since 11.3
*/
- protected function loadDocument()
+ public function loadDocument(JDocument $document = null)
{
- $this->document = JFactory::getDocument();
+ $this->document = ($document === null) ? JFactory::getDocument() : $document;
+
+ return $this;
}
/**
- * Method to create a language for the Web application. The logic and options for creating this
- * object are adequately generic for default cases but for many applications it will make sense
- * to override this method and create language objects based on more specific needs.
+ * Allows the application to load a custom or default document.
*
- * @return void
+ * The logic and options for creating this object are adequately generic for default cases
+ * but for many applications it will make sense to override this method and create an language,
+ * if required, based on more specific needs.
+ *
+ * @param JLanguage $language An optional language object. If omitted, the factory language is created.
+ *
+ * @return JApplicationWeb This method is chainable.
*
* @since 11.3
*/
- protected function loadLanguage()
+ public function loadLanguage(JLanguage $language = null)
{
- $this->language = JFactory::getLanguage();
+ $this->language = ($language === null) ? JFactory::getLanguage() : $language;
+
+ return $this;
}
/**
- * Method to create a session for the Web application. The logic and options for creating this
- * object are adequately generic for default cases but for many applications it will make sense
- * to override this method and create session objects based on more specific needs.
+ * Allows the application to load a custom or default document.
*
- * @return void
+ * The logic and options for creating this object are adequately generic for default cases
+ * but for many applications it will make sense to override this method and create a session,
+ * if required, based on more specific needs.
+ *
+ * @param JSession $session An optional session object. If omitted, the session is created.
+ *
+ * @return JApplicationWeb This method is chainable.
*
* @since 11.3
*/
- protected function loadSession()
+ public function loadSession(JSession $session = null)
{
+ if ($session !== null)
+ {
+ $this->session = $session;
+
+ return $this;
+ }
+
// Generate a session name.
$name = md5($this->get('secret') . $this->get('session_name', get_class($this)));
@@ -1073,6 +1058,8 @@ protected function loadSession()
// Set the session object.
$this->session = $session;
+
+ return $this;
}
/**
@@ -201,7 +201,7 @@ public static function getConnectors()
continue;
}
- // Sweet! Our class exists, so now we just need to know if it passes it's test method.
+ // Sweet! Our class exists, so now we just need to know if it passes its test method.
// @deprecated 12.3 Stop checking with test()
if ($class::isSupported() || $class::test())
{
@@ -22,9 +22,9 @@ class JDocumentXml extends JDocument
* Document name
*
* @var string
- * @since 11.1
+ * @since 12.1
*/
- protected $_name = 'joomla';
+ protected $name = 'joomla';
/**
* Class constructor
@@ -71,7 +71,7 @@ public function render($cache = false, $params = array())
*/
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/**
@@ -85,7 +85,7 @@ public function getName()
*/
public function setName($name = 'joomla')
{
- $this->_name = $name;
+ $this->name = $name;
return $this;
}
Oops, something went wrong.

0 comments on commit 0c920a2

Please sign in to comment.