Skip to content

Commit 82673f0

Browse files
committed
add namespace autoloader
1 parent 24ccd90 commit 82673f0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

core/php/core.inc.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,17 @@
4747
}
4848

4949
function jeedomAutoload($_classname) {
50+
// namespaced class :
51+
// remove 'jeedom' from namespace and replace \ by /
52+
// jeedom\core\class\eqLogic --> __DIR__/core/class/eqLogic.class.php
53+
// jeedom\plugin\atlas\core\class\atlas --> __DIR__/plugin/atlas/core/class/atlas.class.php
54+
// jeedom\core\class\repo\github --> __DIR__/core/class/repo/github.class.php
55+
$nspath = __DIR__ .'/../..' . str_replace( ['jeedom\\', '\\'], ['/', '/'], $_classname) . '.class.php';
5056
/* core class always in /core/class : */
5157
$path = __DIR__ . "/../../core/class/$_classname.class.php";
52-
if (file_exists($path)) {
58+
if (file_exists( $nspath)) {
59+
require_once $nspath;
60+
} else if (file_exists($path)) {
5361
include_file('core', $_classname, 'class');
5462
} else if (substr($_classname, 0, 4) === 'com_') {
5563
/* class com_$1 in /core/com/$1.com.php */

0 commit comments

Comments
 (0)