public static function createComponent($requestedType)
{
$type = static::prado3NamespaceToPhpNamespace($requestedType);
if (!isset(self::$classExists[$type])) {
self::$classExists[$type] = class_exists($type, false);
}
if (!isset(self::$_usings[$type]) && !self::$classExists[$type]) {
static::using($type);
self::$classExists[$type] = class_exists($type, false);
}
/*
* Old apps compatibility support: if the component name has been specified using the
* old namespace syntax (eg. Application.Common.MyDataModule), assume that the calling
* code expects the class not to be php5.3-namespaced (eg: MyDataModule instead of
* \Application\Common\MyDataModule)
* Skip this if the class is inside the Prado\* namespace, since all Prado classes are now namespaced
*/
if (($pos = strrpos($type, '\\')) !== false && $requestedType != $type && strpos($type, 'Prado\\') !== 0) {
$type = substr($type, $pos + 1);
}
if (($n = func_num_args()) > 1) {
$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();
}
}