Skip to content

Commit

Permalink
Merge pull request joomla#947 from LouisLandry/legacy
Browse files Browse the repository at this point in the history
Legacy class path for gracefully deprecating libraries.
  • Loading branch information
ianmacl committed Mar 2, 2012
2 parents dd7d104 + 6448c95 commit 12f00b8
Show file tree
Hide file tree
Showing 60 changed files with 124 additions and 117 deletions.
66 changes: 66 additions & 0 deletions libraries/import.legacy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* @package Joomla.Platform
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

// Set the platform root path as a constant if necessary.
if (!defined('JPATH_PLATFORM'))
{
define('JPATH_PLATFORM', __DIR__);
}

// Detect the native operating system type.
$os = strtoupper(substr(PHP_OS, 0, 3));
if (!defined('IS_WIN'))
{
define('IS_WIN', ($os === 'WIN') ? true : false);
}
if (!defined('IS_MAC'))
{
define('IS_MAC', ($os === 'MAC') ? true : false);
}
if (!defined('IS_UNIX'))
{
define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')) ? true : false);
}

// Import the platform version library if necessary.
if (!class_exists('JPlatform'))
{
require_once JPATH_PLATFORM . '/platform.php';
}

// Import the library loader if necessary.
if (!class_exists('JLoader'))
{
require_once JPATH_PLATFORM . '/loader.php';
}

class_exists('JLoader') or die;

// Register the legacy library base path for deprecated or legacy libraries.
JLoader::registerPrefix('J', JPATH_PLATFORM . '/legacy');

// Setup the autoloaders.
JLoader::setup();

// Import the base Joomla Platform libraries.
JLoader::import('joomla.factory');
JLoader::import('joomla.base.object');

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

// Register classes where the names have been changed to fit the autoloader rules
// @deprecated 12.3
JLoader::register('JDatabaseQueryMySQL', JPATH_PLATFORM . '/database/query/mysql.php');
JLoader::register('JDatabaseQueryMySQLi', JPATH_PLATFORM . '/database/query/mysqli.php');
JLoader::register('JDatabaseQuerySQLAzure', JPATH_PLATFORM . '/database/query/sqlazure.php');
JLoader::register('JDatabaseQuerySQLSrv', JPATH_PLATFORM . '/database/query/sqlsrv.php');
11 changes: 0 additions & 11 deletions libraries/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,7 @@ class_exists('JLoader') or die;

// Import the base Joomla Platform libraries.
JLoader::import('joomla.factory');
JLoader::import('joomla.error.exception');

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

// Register classes where the names have been changed to fit the autoloader rules
// @deprecated 12.3
JLoader::register('JDatabaseQueryMySQL', JPATH_PLATFORM . '/database/query/mysql.php');
JLoader::register('JDatabaseQueryMySQLi', JPATH_PLATFORM . '/database/query/mysqli.php');
JLoader::register('JDatabaseQuerySQLAzure', JPATH_PLATFORM . '/database/query/sqlazure.php');
JLoader::register('JDatabaseQuerySQLSrv', JPATH_PLATFORM . '/database/query/sqlsrv.php');
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Platform
* @subpackage Error
* @subpackage Profiler
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
Expand All @@ -14,7 +14,7 @@
* of sections of code to understand where time is being spent.
*
* @package Joomla.Platform
* @subpackage Error
* @subpackage Profiler
* @since 11.1
*/
class JProfiler
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Platform
* @subpackage Error
* @subpackage Exception
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
Expand All @@ -13,7 +13,7 @@
* Joomla! Exception object.
*
* @package Joomla.Platform
* @subpackage Error
* @subpackage Exception
* @since 11.1
* @deprecated 12.1
*/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">libraries/joomla</directory>
<directory suffix=".php">libraries/legacy</directory>
<file>libraries/import.php</file>
<file>libraries/loader.php</file>
<file>libraries/platform.php</file>
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}

// Import the platform.
require_once JPATH_PLATFORM . '/import.php';
require_once JPATH_PLATFORM . '/import.legacy.php';

// Include the base test cases.
require_once JPATH_TESTS . '/includes/JoomlaTestCase.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/includes/JoomlaTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ protected function restoreFactoryState()
public function getMockApplication()
{
// Load the real class first otherwise the mock will be used if jimport is called again.
require_once JPATH_PLATFORM . '/joomla/application/application.php';
require_once JPATH_PLATFORM . '/legacy/application/application.php';

// Load the mock class builder.
require_once JPATH_TESTS . '/includes/mocks/JApplicationMock.php';
Expand Down
23 changes: 11 additions & 12 deletions tests/suite/joomla/application/component/JControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

require_once JPATH_PLATFORM . '/joomla/application/component/controller.php';
require_once JPATH_PLATFORM . '/joomla/environment/request.php';

/**
* Test class for JController.
Expand Down Expand Up @@ -64,12 +63,12 @@ public function testAddModelPath()
public function testCreateFileName()
{
$parts = array('name' => 'test');

$this->assertThat(
JControllerInspector::createFileName('controller', $parts),
$this->equalTo('test.php')
);

$parts['format'] = 'html';

$this->assertThat(
Expand All @@ -83,36 +82,36 @@ public function testCreateFileName()
JControllerInspector::createFileName('controller', $parts),
$this->equalTo('test.json.php')
);

$parts = array('name' => 'TEST', 'format' => 'JSON');

$this->assertThat(
JControllerInspector::createFileName('controller', $parts),
$this->equalTo('test.json.php')
);

$parts = array('name' => 'test');

$this->assertThat(
JControllerInspector::createFileName('view', $parts),
$this->equalTo('test/view.php')
);

$parts['type'] = 'json';

$this->assertThat(
JControllerInspector::createFileName('view', $parts),
$this->equalTo('test/view.json.php')
);

$parts = array('type' => 'JSON', 'name' => 'TEST');

$this->assertThat(
JControllerInspector::createFileName('view', $parts),
$this->equalTo('test/view.json.php')
);
}

/**
* @todo Implement testGetInstance().
*/
Expand Down Expand Up @@ -178,7 +177,7 @@ public function testAddPath()
'Line:' . __LINE__ . ' The path type should be present, clean and with a trailing slash.'
);
}

/**
* Test JController::addViewPath
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

include_once JPATH_PLATFORM . '/joomla/error/profiler.php';

/**
* Test class for JProfiler.
* Generated by PHPUnit on 2011-10-26 at 19:34:10.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

require_once JPATH_PLATFORM.'/joomla/application/helper.php';

class JApplicationHelperInspector extends JApplicationHelper
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

require_once JPATH_PLATFORM . '/joomla/input/input.php';
require_once JPATH_PLATFORM . '/joomla/environment/request.php';
require_once JPATH_PLATFORM . '/joomla/application/application.php';

/**
* Test class for JApplication.
* Generated by PHPUnit on 2009-10-08 at 11:53:44.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

require_once JPATH_PLATFORM.'/joomla/application/categories.php';

/**
* Test class for JCategories.
* Generated by PHPUnit on 2009-10-08 at 11:55:02.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

require_once JPATH_PLATFORM.'/joomla/application/categories.php';

/**
* Test class for JCategoryNode.
* Generated by PHPUnit on 2009-10-08 at 11:55:26.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

include_once JPATH_PLATFORM . '/joomla/error/error.php';

/**
* Test class for JError.
* Generated by PHPUnit on 2011-10-26 at 19:34:13.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

include_once JPATH_PLATFORM . '/joomla/error/exception.php';

/**
* Test class for JException.
* Generated by PHPUnit on 2011-10-26 at 19:34:12.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class JFormFieldHelpsiteTest extends JoomlaTestCase
*/
protected function setUp()
{
require_once JPATH_PLATFORM . '/cms/help/help.php';
require_once JPATH_PLATFORM . '/cms/form/field/helpsite.php';
require_once JPATH_PLATFORM . '/legacy/help/help.php';
require_once JPATH_PLATFORM . '/legacy/form/field/helpsite.php';
include_once dirname(dirname(dirname(__DIR__))) . '/joomla/form/inspectors.php';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class JFormFieldMediaTest extends JoomlaTestCase
*/
protected function setUp()
{
require_once JPATH_PLATFORM . '/cms/form/field/media.php';
require_once JPATH_PLATFORM . '/legacy/form/field/media.php';
include_once dirname(dirname(dirname(__DIR__))) . '/joomla/form/inspectors.php';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class JFormFieldTemplateStyleTest extends JoomlaTestCase
*/
protected function setUp()
{
require_once JPATH_PLATFORM.'/cms/form/field/templatestyle.php';
require_once JPATH_PLATFORM.'/legacy/form/field/templatestyle.php';
include_once JPATH_TESTS . '/suite/joomla/form/inspectors.php';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class JFormFieldUserTest extends JoomlaTestCase
*/
protected function setUp()
{
require_once JPATH_PLATFORM . '/cms/form/field/user.php';
require_once JPATH_PLATFORM . '/legacy/form/field/user.php';
include_once dirname(dirname(dirname(__DIR__))) . '/joomla/form/inspectors.php';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

require_once JPATH_PLATFORM.'/joomla/application/menu.php';

/**
* Test class for JMenu.
* Generated by PHPUnit on 2009-10-08 at 12:49:26.
Expand Down
Loading

0 comments on commit 12f00b8

Please sign in to comment.