Permalink
Browse files

Merge pull request #1139 from realityking/autoloader

Make more classes autoloadable.
  • Loading branch information...
2 parents c3d1e63 + 5a2752c commit c61114b73fc9a8133d13fadf3ca582ae0c61f14a @LouisLandry LouisLandry committed Apr 14, 2012
Showing with 169 additions and 142 deletions.
  1. +2 −4 libraries/import.legacy.php
  2. +6 −8 libraries/joomla/application/base.php
  3. +2 −2 libraries/joomla/application/cli.php
  4. +2 −2 libraries/joomla/application/daemon.php
  5. +1 −1 libraries/joomla/application/web.php
  6. +2 −2 libraries/joomla/{utilities → date}/date.php
  7. +6 −6 libraries/joomla/event/dispatcher.php
  8. +0 −1 libraries/joomla/factory.php
  9. +0 −2 libraries/joomla/html/editor.php
  10. +1 −1 libraries/joomla/html/html/content.php
  11. +4 −4 libraries/joomla/installer/installer.php
  12. +0 −2 libraries/joomla/log/entry.php
  13. +10 −10 libraries/joomla/plugin/helper.php
  14. +1 −3 libraries/joomla/user/authentication.php
  15. +1 −1 libraries/joomla/user/helper.php
  16. +2 −2 libraries/joomla/user/user.php
  17. +0 −4 libraries/legacy/application/application.php
  18. +0 −2 libraries/legacy/base/tree.php
  19. +32 −0 libraries/legacy/dispatcher/dispatcher.php
  20. +0 −2 libraries/legacy/error/error.php
  21. +3 −3 libraries/legacy/model/admin.php
  22. +1 −1 libraries/legacy/model/form.php
  23. +1 −1 libraries/legacy/model/model.php
  24. +4 −4 libraries/{joomla/utilities → legacy/simplecrypt}/simplecrypt.php
  25. +2 −2 tests/core/case/case.php
  26. +2 −2 tests/core/case/database.php
  27. +4 −4 tests/core/mock/dispatcher.php
  28. +6 −4 tests/suites/{unit/joomla/utilities → legacy/simplecrypt}/JSimpleCryptTest.php
  29. +4 −4 tests/suites/unit/joomla/application/JApplicationBaseTest.php
  30. +2 −2 tests/suites/unit/joomla/application/JApplicationCliTest.php
  31. +7 −7 tests/suites/unit/joomla/application/JApplicationWebTest.php
  32. +16 −4 tests/suites/unit/joomla/{utilities → date}/JDateTest.php
  33. +3 −3 tests/suites/unit/joomla/event/{JDispatcherInspector.php → JEventDispatcherInspector.php}
  34. +31 −31 tests/suites/unit/joomla/event/{JDispatcherTest.php → JEventDispatcherTest.php}
  35. +3 −3 tests/suites/unit/joomla/event/JEventInspector.php
  36. +3 −3 tests/suites/unit/joomla/event/JEventTest.php
  37. +1 −1 tests/suites/unit/joomla/language/JLanguageInspector.php
  38. +4 −4 tests/suites/unit/joomla/user/JAuthenticationTest.php
@@ -50,9 +50,6 @@ class_exists('JLoader') or die;
// Import the Joomla Factory.
JLoader::import('joomla.factory');
-// Register JRequest for legacy reasons
-JLoader::register('JRequest', JPATH_PLATFORM . '/joomla/environment/request.php');
-
// Register classes that don't follow one file per class naming conventions.
JLoader::register('JText', JPATH_PLATFORM . '/joomla/language/text.php');
JLoader::register('JRoute', JPATH_PLATFORM . '/joomla/application/route.php');
@@ -64,5 +61,6 @@ class_exists('JLoader') or die;
JLoader::register('JDatabaseQuerySQLAzure', JPATH_PLATFORM . '/joomla/database/query/sqlazure.php');
JLoader::register('JDatabaseQuerySQLSrv', JPATH_PLATFORM . '/joomla/database/query/sqlsrv.php');
JLoader::register('JToolBar', JPATH_PLATFORM . '/legacy/toolbar/toolbar.php');
+JLoader::register('JSimpleCrypt', JPATH_PLATFORM . '/legacy/simplecrypt/simplecrypt.php');
JLoader::register('JTree', JPATH_PLATFORM . '/legacy/base/tree.php');
-JLoader::register('JNode', JPATH_PLATFORM . '/legacy/base/node.php');
+JLoader::register('JNode', JPATH_PLATFORM . '/legacy/base/node.php');
@@ -9,8 +9,6 @@
defined('JPATH_PLATFORM') or die;
-jimport('joomla.event.dispatcher');
-
/**
* Joomla Platform Base Application Class
*
@@ -23,7 +21,7 @@
/**
* The application dispatcher object.
*
- * @var JDispatcher
+ * @var JEventDispatcher
* @since 12.1
*/
protected $dispatcher;
@@ -83,7 +81,7 @@ public function getIdentity()
*/
public function registerEvent($event, $handler)
{
- if ($this->dispatcher instanceof JDispatcher)
+ if ($this->dispatcher instanceof JEventDispatcher)
{
$this->dispatcher->register($event, $handler);
}
@@ -103,7 +101,7 @@ public function registerEvent($event, $handler)
*/
public function triggerEvent($event, array $args = null)
{
- if ($this->dispatcher instanceof JDispatcher)
+ if ($this->dispatcher instanceof JEventDispatcher)
{
return $this->dispatcher->trigger($event, $args);
}
@@ -118,15 +116,15 @@ public function triggerEvent($event, array $args = null)
* 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.
+ * @param JEventDispatcher $dispatcher An optional dispatcher object. If omitted, the factory dispatcher is created.
*
* @return JApplicationBase This method is chainable.
*
* @since 12.1
*/
- public function loadDispatcher(JDispatcher $dispatcher = null)
+ public function loadDispatcher(JEventDispatcher $dispatcher = null)
{
- $this->dispatcher = ($dispatcher === null) ? JDispatcher::getInstance() : $dispatcher;
+ $this->dispatcher = ($dispatcher === null) ? JEventDispatcher::getInstance() : $dispatcher;
return $this;
}
@@ -40,14 +40,14 @@ class JApplicationCli extends JApplicationBase
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
- * event dispatcher. If the argument is a JDispatcher object that object will become
+ * event dispatcher. If the argument is a JEventDispatcher object that object will become
* the application's event dispatcher, if it is null then the default event dispatcher
* will be created based on the application's loadDispatcher() method.
*
* @see loadDispatcher()
* @since 11.1
*/
- public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
+ public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
{
// Close the application if we are not executed from the command line.
// @codeCoverageIgnoreStart
@@ -100,14 +100,14 @@ class JApplicationDaemon extends JApplicationCli
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
- * event dispatcher. If the argument is a JDispatcher object that object will become
+ * event dispatcher. If the argument is a JEventDispatcher object that object will become
* the application's event dispatcher, if it is null then the default event dispatcher
* will be created based on the application's loadDispatcher() method.
*
* @since 11.1
* @throws RuntimeException
*/
- public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
+ public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
{
// Verify that the process control extension for PHP is available.
// @codeCoverageIgnoreStart
@@ -195,7 +195,7 @@ public static function getInstance($name = null)
* object, and if it is null then the default language object will be created based
* on the application's loadLanguage() method.
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
- * event dispatcher. If the argument is a JDispatcher object that object will become
+ * event dispatcher. If the argument is a JEventDispatcher object that object will become
* the application's event dispatcher, if it is null then the default event dispatcher
* will be created based on the application's loadDispatcher() method.
*
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Platform
- * @subpackage Utilities
+ * @subpackage Date
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
@@ -27,7 +27,7 @@
* @property-read string $year Y - A full numeric representation of a year, 4 digits.
*
* @package Joomla.Platform
- * @subpackage Utilities
+ * @subpackage Date
* @since 11.1
*/
class JDate extends DateTime
@@ -19,9 +19,9 @@
* @subpackage Event
* @link http://docs.joomla.org/Tutorial:Plugins Plugin tutorials
* @see JPlugin
- * @since 11.1
+ * @since 12.1
*/
-class JDispatcher extends JObject
+class JEventDispatcher extends JObject
{
/**
* An array of Observer objects to notify
@@ -50,7 +50,7 @@ class JDispatcher extends JObject
/**
* Stores the singleton instance of the dispatcher.
*
- * @var JDispatcher
+ * @var JEventDispatcher
* @since 11.3
*/
protected static $instance = null;
@@ -59,22 +59,22 @@ class JDispatcher extends JObject
* Returns the global Event Dispatcher object, only creating it
* if it doesn't already exist.
*
- * @return JDispatcher The EventDispatcher object.
+ * @return JEventDispatcher The EventDispatcher object.
*
* @since 11.1
*/
public static function getInstance()
{
if (self::$instance === null)
{
- self::$instance = new JDispatcher;
+ self::$instance = new static;
}
return self::$instance;
}
/**
- * Get the state of the JDispatcher object
+ * Get the state of the JEventDispatcher object
*
* @return mixed The state of the object.
*
@@ -470,7 +470,6 @@ public static function getURI($uri = 'SERVER')
*/
public static function getDate($time = 'now', $tzOffset = null)
{
- jimport('joomla.utilities.date');
static $classname;
static $mainLocale;
@@ -9,8 +9,6 @@
defined('JPATH_PLATFORM') or die;
-jimport('joomla.event.dispatcher');
-
/**
* JEditor class to handle WYSIWYG editors
*
@@ -38,7 +38,7 @@ public static function prepare($text, $params = null, $context = 'text')
$article = new stdClass;
$article->text = $text;
JPluginHelper::importPlugin('content');
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onContentPrepare', array($context, &$article, &$params, 0));
return $article->text;
@@ -436,7 +436,7 @@ public function install($path = null)
// Fire the onExtensionBeforeInstall event.
JPluginHelper::importPlugin('extension');
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger(
'onExtensionBeforeInstall',
array('method' => 'install', 'type' => $type, 'manifest' => $this->manifest, 'extension' => 0)
@@ -514,7 +514,7 @@ public function discover_install($eid = null)
// Fire the onExtensionBeforeInstall event.
JPluginHelper::importPlugin('extension');
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger(
'onExtensionBeforeInstall',
array(
@@ -629,7 +629,7 @@ public function update($path = null)
// Fire the onExtensionBeforeUpdate event.
JPluginHelper::importPlugin('extension');
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onExtensionBeforeUpdate', array('type' => $type, 'manifest' => $this->manifest));
// Run the update
@@ -681,7 +681,7 @@ public function uninstall($type, $identifier, $cid = 0)
// We don't load languages here, we get the extension adapter to work it out
// Fire the onExtensionBeforeUninstall event.
JPluginHelper::importPlugin('extension');
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onExtensionBeforeUninstall', array('eid' => $identifier));
// Run the uninstall
@@ -9,8 +9,6 @@
defined('JPATH_PLATFORM') or die;
-jimport('joomla.utilities.date');
-
/**
* Joomla! Log Entry class
*
@@ -90,16 +90,16 @@ public static function isEnabled($type, $plugin = null)
* Loads all the plugin files for a particular type if no specific plugin is specified
* otherwise only the specific plugin is loaded.
*
- * @param string $type The plugin type, relates to the sub-directory in the plugins directory.
- * @param string $plugin The plugin name.
- * @param boolean $autocreate Autocreate the plugin.
- * @param JDispatcher $dispatcher Optionally allows the plugin to use a different dispatcher.
+ * @param string $type The plugin type, relates to the sub-directory in the plugins directory.
+ * @param string $plugin The plugin name.
+ * @param boolean $autocreate Autocreate the plugin.
+ * @param JEventDispatcher $dispatcher Optionally allows the plugin to use a different dispatcher.
*
* @return boolean True on success.
*
* @since 11.1
*/
- public static function importPlugin($type, $plugin = null, $autocreate = true, $dispatcher = null)
+ public static function importPlugin($type, $plugin = null, $autocreate = true, JEventDispatcher $dispatcher = null)
{
static $loaded = array();
@@ -141,15 +141,15 @@ public static function importPlugin($type, $plugin = null, $autocreate = true, $
/**
* Loads the plugin file.
*
- * @param JPlugin $plugin The plugin.
- * @param boolean $autocreate True to autocreate.
- * @param JDispatcher $dispatcher Optionally allows the plugin to use a different dispatcher.
+ * @param JPlugin $plugin The plugin.
+ * @param boolean $autocreate True to autocreate.
+ * @param JEventDispatcher $dispatcher Optionally allows the plugin to use a different dispatcher.
*
* @return boolean True on success.
*
* @since 11.1
*/
- protected static function _import($plugin, $autocreate = true, $dispatcher = null)
+ protected static function _import($plugin, $autocreate = true, JEventDispatcher $dispatcher = null)
{
static $paths = array();
@@ -177,7 +177,7 @@ protected static function _import($plugin, $autocreate = true, $dispatcher = nul
// Makes sure we have an event dispatcher
if (!is_object($dispatcher))
{
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
}
$className = 'plg' . $plugin->type . $plugin->name;
@@ -9,8 +9,6 @@
defined('JPATH_PLATFORM') or die;
-jimport('joomla.event.dispatcher');
-
/**
* Authentication class, provides an interface for the Joomla authentication system
*
@@ -331,7 +329,7 @@ public static function authorise($response, $options = array())
// Get plugins in case they haven't been loaded already
JPluginHelper::getPlugin('user');
JPluginHelper::getPlugin('authentication');
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
$results = $dispatcher->trigger('onUserAuthorisation', array($response, $options));
return $results;
}
@@ -202,7 +202,7 @@ public function getProfile($userId = 0)
}
// Get the dispatcher and load the user's plugins.
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('user');
$data = new JObject;
@@ -708,7 +708,7 @@ public function save($updateOnly = false)
// Fire the onUserBeforeSave event.
JPluginHelper::importPlugin('user');
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
$result = $dispatcher->trigger('onUserBeforeSave', array($oldUser->getProperties(), $isNew, $this->getProperties()));
if (in_array(false, $result, true))
@@ -758,7 +758,7 @@ public function delete()
JPluginHelper::importPlugin('user');
// Trigger the onUserBeforeDelete event
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onUserBeforeDelete', array($this->getProperties()));
// Create the user table object
@@ -88,8 +88,6 @@ class JApplication extends JApplicationBase
*/
public function __construct($config = array())
{
- jimport('joomla.error.profiler');
-
// Set the view name.
$this->_name = $this->getName();
@@ -670,8 +668,6 @@ public function login($credentials, $options = array())
// Set the remember me cookie if enabled.
if (isset($options['remember']) && $options['remember'])
{
- jimport('joomla.utilities.simplecrypt');
-
// Create the encryption key, apply extra hardening using the user agent string.
$key = self::getHash(@$_SERVER['HTTP_USER_AGENT']);
@@ -9,8 +9,6 @@
defined('JPATH_PLATFORM') or die;
-jimport('joomla.base.node');
-
/**
* Tree Class.
*
Oops, something went wrong.

0 comments on commit c61114b

Please sign in to comment.