From 0093239f4e5d221c6c74cfc415877c951e7687b5 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 8 Aug 2015 20:46:01 +0200 Subject: Fix Prado::using and Prado::createComponent - Prado::using for interfaces - fix Prado:using for single files (must be aliased too) --- framework/PradoBase.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'framework/PradoBase.php') diff --git a/framework/PradoBase.php b/framework/PradoBase.php index 8813940a..acbee859 100644 --- a/framework/PradoBase.php +++ b/framework/PradoBase.php @@ -250,9 +250,9 @@ class PradoBase * @return TComponent component instance of the specified type * @throws TInvalidDataValueException if the component type is unknown */ - public static function createComponent($type) + public static function createComponent($requestedType) { - $type = static::prado3NamespaceToPhpNamespace($type); + $type = static::prado3NamespaceToPhpNamespace($requestedType); if(!isset(self::$classExists[$type])) self::$classExists[$type] = class_exists($type, false); @@ -262,7 +262,7 @@ class PradoBase self::$classExists[$type] = class_exists($type, false); } - if( ($pos = strrpos($type, '\\')) !== false) + if( ($pos = strrpos($type, '\\')) !== false & ($requestedType != $type)) $type = substr($type,$pos+1); if(($n=func_num_args())>1) @@ -318,9 +318,10 @@ class PradoBase if(file_exists($path)) { $phpNamespace = '\\'. $k.'\\'.$namespace; - if(class_exists($phpNamespace, true)) + if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) { - class_alias($phpNamespace, $namespace, true); + if(!class_exists($namespace) && !interface_exists($namespace)) + class_alias($phpNamespace, $namespace, true); return; } } @@ -339,11 +340,13 @@ class PradoBase else // a file { //self::$_usings[$namespace]=$path; - if(!$checkClassExistence || !class_exists($className,false)) + if(!$checkClassExistence || (!class_exists($className,false) && !interface_exists($className, false))) { try { include_once($path); + if(class_exists($namespace, false) || interface_exists($namespace, false)) + class_alias($namespace, $className, true); } catch(\Exception $e) { -- cgit v1.2.3