Browse Source

Merge branch 'master' of github.com:yiisoft/yii2

* 'master' of github.com:yiisoft/yii2:
  Removed Yii::import().
tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
75391b7515
  1. 39
      framework/yii/YiiBase.php
  2. 2
      framework/yii/validators/ExistValidator.php
  3. 2
      framework/yii/validators/UniqueValidator.php
  4. 2
      framework/yii/web/User.php

39
framework/yii/YiiBase.php

@ -100,7 +100,6 @@ class YiiBase
*/ */
public static $objectConfig = array(); public static $objectConfig = array();
private static $_imported = array(); // alias => class name or directory
/** /**
* @return string the version of Yii framework * @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. * Imports a set of namespaces.
* *
* By importing a namespace, the method will create an alias for the directory corresponding * 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.'); 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, '\\'); $class = ltrim($class, '\\');
if (isset(self::$objectConfig[$class])) { if (isset(self::$objectConfig[$class])) {

2
framework/yii/validators/ExistValidator.php

@ -66,7 +66,7 @@ class ExistValidator extends Validator
} }
/** @var $className \yii\db\ActiveRecord */ /** @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; $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
$query = $className::find(); $query = $className::find();
$query->where(array($attributeName => $value)); $query->where(array($attributeName => $value));

2
framework/yii/validators/UniqueValidator.php

@ -61,7 +61,7 @@ class UniqueValidator extends Validator
} }
/** @var $className \yii\db\ActiveRecord */ /** @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; $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
$table = $className::getTableSchema(); $table = $className::getTableSchema();

2
framework/yii/web/User.php

@ -140,7 +140,7 @@ class User extends Component
$this->_identity = null; $this->_identity = null;
} else { } else {
/** @var $class Identity */ /** @var $class Identity */
$class = Yii::import($this->identityClass); $class = $this->identityClass;
$this->_identity = $class::findIdentity($id); $this->_identity = $class::findIdentity($id);
} }
} }

Loading…
Cancel
Save