1212 * @package Core
1313 */
1414
15+ use Horde \Util \HordeString ;
16+
1517/**
1618 * The Horde_Core_Ui_VarRenderer:: class provides base functionality for other
1719 * Horde UI elements.
@@ -46,12 +48,12 @@ public function __construct($params = [])
4648 *
4749 * @param mixed $driver This is the renderer subclass we will instantiate.
4850 * If an array is passed, the first element is the
49- * library path and the second element is the driver
50- * name.
51+ * application name and the second element is the
52+ * driver name.
5153 * @param array $params Parameters specific to the subclass.
5254 *
5355 * @return Horde_Core_Ui_VarRenderer A subclass instance.
54- * @throws Horde_Exception
56+ * @throws LogicException
5557 */
5658 public static function factory ($ driver , $ params = [])
5759 {
@@ -62,24 +64,29 @@ public static function factory($driver, $params = [])
6264 $ app = '' ;
6365 }
6466
65- $ driver = Horde_String::ucfirst (basename ($ driver ));
66- $ class = (empty ($ app ) ? 'Horde_Core ' : $ app ) . '_Ui_VarRenderer_ ' . $ driver ;
67+ $ driver = HordeString::ucfirst (basename ($ driver ));
6768
68- $ ok = class_exists ($ class );
69+ if (!empty ($ app )) {
70+ // Try ucfirst app name first (e.g. Nag_Ui_VarRenderer_Html)
71+ $ class = HordeString::ucfirst ($ app ) . '_Ui_VarRenderer_ ' . $ driver ;
72+ if (class_exists ($ class )) {
73+ return new $ class ($ params );
74+ }
6975
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 ;
74- include_once $ GLOBALS ['registry ' ]->get ('fileroot ' , $ app ) . '/lib/Ui/VarRenderer/ ' . $ driver . '.php ' ;
75- $ ok = class_exists ($ class );
76+ // Try lowercase app name (e.g. nag_Ui_VarRenderer_Html)
77+ $ class = strtolower ($ app ) . '_Ui_VarRenderer_ ' . $ driver ;
78+ if (class_exists ($ class )) {
79+ return new $ class ($ params );
80+ }
7681 }
7782
78- if (!$ ok ) {
79- throw new LogicException ('Class definition of ' . $ class . ' not found. ' );
83+ // Fall back to core renderer (Horde_Core_Ui_VarRenderer_{Driver})
84+ $ class = __CLASS__ . '_ ' . $ driver ;
85+ if (class_exists ($ class )) {
86+ return new $ class ($ params );
8087 }
8188
82- return new $ class ( $ params );
89+ throw new LogicException ( ' Class definition of ' . $ class . ' not found. ' );
8390 }
8491
8592 /**
0 commit comments