summaryrefslogtreecommitdiff
path: root/framework/PradoBase.php
diff options
context:
space:
mode:
authorChristophe.Boulain <>2009-07-15 09:01:05 +0000
committerChristophe.Boulain <>2009-07-15 09:01:05 +0000
commit3ba065922fadd3dfc9e60014690e139a5568f8a9 (patch)
tree232f99f1a77b64def015fce4445bf572773f93ca /framework/PradoBase.php
parentf1c27f46100582a1e52a27b616bf468e849068e7 (diff)
Merging latests 3.1 changes into trunk
Diffstat (limited to 'framework/PradoBase.php')
-rw-r--r--framework/PradoBase.php47
1 files changed, 38 insertions, 9 deletions
diff --git a/framework/PradoBase.php b/framework/PradoBase.php
index 084dd62b..3bf747df 100644
--- a/framework/PradoBase.php
+++ b/framework/PradoBase.php
@@ -62,6 +62,11 @@ class PradoBase
private static $_logger=null;
/**
+ * @var array list of class exists checks
+ */
+ protected static $classExists = array();
+
+ /**
* @return string the version of Prado framework
*/
public static function getVersion()
@@ -226,17 +231,41 @@ class PradoBase
*/
public static function createComponent($type)
{
- self::using($type);
- if(($pos=strrpos($type,'.'))!==false)
- $type=substr($type,$pos+1);
+ if(!isset(self::$classExists[$type]))
+ self::$classExists[$type] = class_exists($type, false);
+
+ if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) {
+ self::using($type);
+ self::$classExists[$type] = class_exists($type, false);
+ }
+
+ if( ($pos = strrpos($type, '.')) !== false)
+ $type = substr($type,$pos+1);
+
if(($n=func_num_args())>1)
{
- $args=func_get_args();
- $s='$args[1]';
- for($i=2;$i<$n;++$i)
- $s.=",\$args[$i]";
- eval("\$component=new $type($s);");
- return $component;
+ $args = func_get_args();
+ switch($n) {
+ case 2:
+ return new $type($args[1]);
+ break;
+ case 3:
+ return new $type($args[1], $args[2]);
+ break;
+ case 4:
+ return new $type($args[1], $args[2], $args[3]);
+ break;
+ case 5:
+ return new $type($args[1], $args[2], $args[3], $args[4]);
+ break;
+ default:
+ $s='$args[1]';
+ for($i=2;$i<$n;++$i)
+ $s.=",\$args[$i]";
+ eval("\$component=new $type($s);");
+ return $component;
+ break;
+ }
}
else
return new $type;