diff options
author | David <ottodavid@gmx.net> | 2015-08-08 20:46:01 +0200 |
---|---|---|
committer | David <ottodavid@gmx.net> | 2015-08-08 21:11:10 +0200 |
commit | 0093239f4e5d221c6c74cfc415877c951e7687b5 (patch) | |
tree | 0427d46607cafb6755b7f99bbff06de239a9c6bf | |
parent | 8b7f06844481deb7ed572c7afb3b3ed3ecf4023c (diff) |
Fix Prado::using and Prado::createComponent
- Prado::using for interfaces
- fix Prado:using for single files (must be aliased too)
-rw-r--r-- | framework/PradoBase.php | 15 |
1 files changed, 9 insertions, 6 deletions
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) { |