Skip to content

Commit 55d860f

Browse files
authored
Merge pull request #29 from amulet1/autoload-fixes
Add support for autoloading of *_Ui_VarRenderer_* classes
2 parents 068ab4f + f260109 commit 55d860f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/Horde/Core/Ui/VarRenderer.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,24 @@ public static function factory($driver, $params = [])
5858
if (is_array($driver)) {
5959
$app = $driver[0];
6060
$driver = $driver[1];
61+
} else {
62+
$app = '';
6163
}
6264

6365
$driver = Horde_String::ucfirst(basename($driver));
64-
if (!empty($app)) {
66+
$class = (empty($app) ? 'Horde_Core' : $app) . '_Ui_VarRenderer_' . $driver;
67+
68+
$ok = class_exists($class);
69+
70+
// TODO: Eliminate after renaming Horde_Ui_VarRenderer_* classes in other apps to {app}_Ui_VarRenderer_*
71+
if (!$ok && !empty($app)) {
72+
// fallback to legacy method (manual load)
73+
$class = __CLASS__ . '_' . $driver;
6574
include_once $GLOBALS['registry']->get('fileroot', $app) . '/lib/Ui/VarRenderer/' . $driver . '.php';
75+
$ok = class_exists($class);
6676
}
6777

68-
$class = __CLASS__ . '_' . $driver;
69-
if (!class_exists($class)) {
78+
if (!$ok) {
7079
throw new LogicException('Class definition of ' . $class . ' not found.');
7180
}
7281

0 commit comments

Comments
 (0)