Commit ea108688 by Qiang Xue

Removed Yii::import().

parent 7a6ce825
......@@ -100,7 +100,6 @@ class YiiBase
*/
public static $objectConfig = array();
private static $_imported = array(); // alias => class name or directory
/**
* @return string the version of Yii framework
......@@ -111,40 +110,6 @@ class YiiBase
}
/**
* Imports a class by its alias.
*
* This method is provided to support autoloading of non-namespaced classes.
* Such a class can be specified in terms of an alias. For example, the alias `@old/code/Sample`
* may represent the `Sample` class under the directory `@old/code` (a path alias).
*
* By importing a class, the class is put in an internal storage such that when
* the class is used for the first time, the class autoloader will be able to
* find the corresponding class file and include it. For this reason, this method
* is much lighter than `include()`.
*
* You may import the same class multiple times. Only the first importing will count.
*
* @param string $alias the class to be imported. This may be either a class alias or a fully-qualified class name.
* If the latter, it will be returned back without change.
* @return string the actual class name that `$alias` refers to
* @throws Exception if the alias is invalid
*/
public static function import($alias)
{
if (strncmp($alias, '@', 1)) {
return $alias;
} else {
$alias = static::getAlias($alias);
if (!isset(self::$_imported[$alias])) {
$className = basename($alias);
self::$_imported[$alias] = $className;
self::$classMap[$className] = $alias . '.php';
}
return self::$_imported[$alias];
}
}
/**
* Imports a set of namespaces.
*
* By importing a namespace, the method will create an alias for the directory corresponding
......@@ -431,10 +396,6 @@ class YiiBase
throw new InvalidConfigException('Object configuration must be an array containing a "class" element.');
}
if (!class_exists($class, false)) {
$class = static::import($class);
}
$class = ltrim($class, '\\');
if (isset(self::$objectConfig[$class])) {
......
......@@ -66,7 +66,7 @@ class ExistValidator extends Validator
}
/** @var $className \yii\db\ActiveRecord */
$className = $this->className === null ? get_class($object) : Yii::import($this->className);
$className = $this->className === null ? get_class($object) : $this->className;
$attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
$query = $className::find();
$query->where(array($attributeName => $value));
......
......@@ -61,7 +61,7 @@ class UniqueValidator extends Validator
}
/** @var $className \yii\db\ActiveRecord */
$className = $this->className === null ? get_class($object) : Yii::import($this->className);
$className = $this->className === null ? get_class($object) : $this->className;
$attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
$table = $className::getTableSchema();
......
......@@ -140,7 +140,7 @@ class User extends Component
$this->_identity = null;
} else {
/** @var $class Identity */
$class = Yii::import($this->identityClass);
$class = $this->identityClass;
$this->_identity = $class::findIdentity($id);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment