Skip to content

Commit

Permalink
Load the Joomla namespace trough JLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Mar 22, 2017
1 parent d18491f commit 55cc1a9
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 59 deletions.
1 change: 1 addition & 0 deletions libraries/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

// Register the library base path for CMS libraries.
JLoader::registerPrefix('J', JPATH_PLATFORM . '/cms', false, true);
JLoader::registerNamespace('Joomla', JPATH_PLATFORM . '/src/Joomla', false, false, 'psr4');

// Create the Composer autoloader
$loader = require JPATH_LIBRARIES . '/vendor/autoload.php';
Expand Down
36 changes: 0 additions & 36 deletions libraries/cms/class/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,47 +52,11 @@ public function __construct(ClassLoader $loader)
*/
public function loadClass($class)
{
// Namespaced class
if ($this->loadFromJLoader($class))
{
return true;
}

// None namespaced class
if ($this->loadFromJLoader('\\' . $class))
{
return true;
}

if ($result = $this->loader->loadClass($class))
{
JLoader::applyAliasFor($class);
}

return $result;
}

/**
* Loads the class from JLoader when possible.
*
* @param string $class The name of the class
*
* @return boolean True if loaded, false otherwise
*
* @since __DEPLOY_VERSION__
*/
private function loadFromJLoader($class)
{
// Check if JLoader is able to load the class
if (!key_exists(strtolower($class), JLoader::getClassList()))
{
return false;
}

// Load the class
JLoader::load($class);

JLoader::applyAliasFor($class);
return true;
}
}
17 changes: 0 additions & 17 deletions libraries/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,6 @@ public static function load($class)
*/
public static function register($class, $path, $force = true)
{
// When an alias exists, register it as well
if (key_exists($class, self::$classAliases))
{
self::register(self::$classAliases[$class], $path, $force);
}

// Sanitize class name.
$class = strtolower($class);

Expand Down Expand Up @@ -642,17 +636,6 @@ class_alias(self::$classAliases[$class], $class);
*/
public static function applyAliasFor($class)
{
// When the class doesn't exists but we have a class available with the key, create the alias
if (!class_exists($class) && $key = array_search($class, self::$classAliases))
{
if (class_exists($key))
{
class_alias($key, $class);
return;
}
}


// Remove the root backslash if present.
if ($class[0] == '\\')
{
Expand Down
1 change: 0 additions & 1 deletion libraries/vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@
'Joomla\\DI\\Tests\\' => array($vendorDir . '/joomla/di/Tests'),
'Joomla\\DI\\' => array($vendorDir . '/joomla/di/src'),
'Joomla\\Application\\' => array($vendorDir . '/joomla/application/src'),
'Joomla\\' => array($baseDir . '/libraries/src/Joomla'),
);
5 changes: 0 additions & 5 deletions libraries/vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class ComposerStaticInit205c915b9c7d3e718e7c95793ee67ffe
'Joomla\\DI\\Tests\\' => 16,
'Joomla\\DI\\' => 10,
'Joomla\\Application\\' => 19,
'Joomla\\' => 7,
),
);

Expand Down Expand Up @@ -152,10 +151,6 @@ class ComposerStaticInit205c915b9c7d3e718e7c95793ee67ffe
array (
0 => __DIR__ . '/..' . '/joomla/application/src',
),
'Joomla\\' =>
array (
0 => __DIR__ . '/../../..' . '/libraries/src/Joomla',
),
);

public static $prefixesPsr0 = array (
Expand Down

0 comments on commit 55cc1a9

Please sign in to comment.