Skip to content

Commit

Permalink
add namespace autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
pifou25 committed Sep 22, 2024
1 parent 24ccd90 commit 82673f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/php/core.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@
}

function jeedomAutoload($_classname) {
// namespaced class :
// remove 'jeedom' from namespace and replace \ by /
// jeedom\core\class\eqLogic --> __DIR__/core/class/eqLogic.class.php
// jeedom\plugin\atlas\core\class\atlas --> __DIR__/plugin/atlas/core/class/atlas.class.php
// jeedom\core\class\repo\github --> __DIR__/core/class/repo/github.class.php
$nspath = __DIR__ .'/../..' . str_replace( ['jeedom\\', '\\'], ['/', '/'], $_classname) . '.class.php';
/* core class always in /core/class : */
$path = __DIR__ . "/../../core/class/$_classname.class.php";
if (file_exists($path)) {
if (file_exists( $nspath)) {
require_once $nspath;
} else if (file_exists($path)) {
include_file('core', $_classname, 'class');
} else if (substr($_classname, 0, 4) === 'com_') {
/* class com_$1 in /core/com/$1.com.php */
Expand Down

0 comments on commit 82673f0

Please sign in to comment.