|
|
|
@ -147,11 +147,11 @@ class BaseYii
|
|
|
|
|
$pos = strpos($alias, '/'); |
|
|
|
|
$root = $pos === false ? $alias : substr($alias, 0, $pos); |
|
|
|
|
|
|
|
|
|
if (isset(self::$aliases[$root])) { |
|
|
|
|
if (is_string(self::$aliases[$root])) { |
|
|
|
|
return $pos === false ? self::$aliases[$root] : self::$aliases[$root] . substr($alias, $pos); |
|
|
|
|
if (isset(static::$aliases[$root])) { |
|
|
|
|
if (is_string(static::$aliases[$root])) { |
|
|
|
|
return $pos === false ? static::$aliases[$root] : static::$aliases[$root] . substr($alias, $pos); |
|
|
|
|
} else { |
|
|
|
|
foreach (self::$aliases[$root] as $name => $path) { |
|
|
|
|
foreach (static::$aliases[$root] as $name => $path) { |
|
|
|
|
if (strpos($alias . '/', $name . '/') === 0) { |
|
|
|
|
return $path . substr($alias, strlen($name)); |
|
|
|
|
} |
|
|
|
@ -178,11 +178,11 @@ class BaseYii
|
|
|
|
|
$pos = strpos($alias, '/'); |
|
|
|
|
$root = $pos === false ? $alias : substr($alias, 0, $pos); |
|
|
|
|
|
|
|
|
|
if (isset(self::$aliases[$root])) { |
|
|
|
|
if (is_string(self::$aliases[$root])) { |
|
|
|
|
if (isset(static::$aliases[$root])) { |
|
|
|
|
if (is_string(static::$aliases[$root])) { |
|
|
|
|
return $root; |
|
|
|
|
} else { |
|
|
|
|
foreach (self::$aliases[$root] as $name => $path) { |
|
|
|
|
foreach (static::$aliases[$root] as $name => $path) { |
|
|
|
|
if (strpos($alias . '/', $name . '/') === 0) { |
|
|
|
|
return $name; |
|
|
|
|
} |
|
|
|
@ -229,30 +229,30 @@ class BaseYii
|
|
|
|
|
$root = $pos === false ? $alias : substr($alias, 0, $pos); |
|
|
|
|
if ($path !== null) { |
|
|
|
|
$path = strncmp($path, '@', 1) ? rtrim($path, '\\/') : static::getAlias($path); |
|
|
|
|
if (!isset(self::$aliases[$root])) { |
|
|
|
|
if (!isset(static::$aliases[$root])) { |
|
|
|
|
if ($pos === false) { |
|
|
|
|
self::$aliases[$root] = $path; |
|
|
|
|
static::$aliases[$root] = $path; |
|
|
|
|
} else { |
|
|
|
|
self::$aliases[$root] = [$alias => $path]; |
|
|
|
|
static::$aliases[$root] = [$alias => $path]; |
|
|
|
|
} |
|
|
|
|
} elseif (is_string(self::$aliases[$root])) { |
|
|
|
|
} elseif (is_string(static::$aliases[$root])) { |
|
|
|
|
if ($pos === false) { |
|
|
|
|
self::$aliases[$root] = $path; |
|
|
|
|
static::$aliases[$root] = $path; |
|
|
|
|
} else { |
|
|
|
|
self::$aliases[$root] = [ |
|
|
|
|
static::$aliases[$root] = [ |
|
|
|
|
$alias => $path, |
|
|
|
|
$root => self::$aliases[$root], |
|
|
|
|
$root => static::$aliases[$root], |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
self::$aliases[$root][$alias] = $path; |
|
|
|
|
krsort(self::$aliases[$root]); |
|
|
|
|
static::$aliases[$root][$alias] = $path; |
|
|
|
|
krsort(static::$aliases[$root]); |
|
|
|
|
} |
|
|
|
|
} elseif (isset(self::$aliases[$root])) { |
|
|
|
|
if (is_array(self::$aliases[$root])) { |
|
|
|
|
unset(self::$aliases[$root][$alias]); |
|
|
|
|
} elseif (isset(static::$aliases[$root])) { |
|
|
|
|
if (is_array(static::$aliases[$root])) { |
|
|
|
|
unset(static::$aliases[$root][$alias]); |
|
|
|
|
} elseif ($pos === false) { |
|
|
|
|
unset(self::$aliases[$root]); |
|
|
|
|
unset(static::$aliases[$root]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -278,8 +278,8 @@ class BaseYii
|
|
|
|
|
*/ |
|
|
|
|
public static function autoload($className) |
|
|
|
|
{ |
|
|
|
|
if (isset(self::$classMap[$className])) { |
|
|
|
|
$classFile = self::$classMap[$className]; |
|
|
|
|
if (isset(static::$classMap[$className])) { |
|
|
|
|
$classFile = static::$classMap[$className]; |
|
|
|
|
if ($classFile[0] === '@') { |
|
|
|
|
$classFile = static::getAlias($classFile); |
|
|
|
|
} |
|
|
|
@ -362,8 +362,8 @@ class BaseYii
|
|
|
|
|
|
|
|
|
|
$class = ltrim($class, '\\'); |
|
|
|
|
|
|
|
|
|
if (isset(self::$objectConfig[$class])) { |
|
|
|
|
$config = array_merge(self::$objectConfig[$class], $config); |
|
|
|
|
if (isset(static::$objectConfig[$class])) { |
|
|
|
|
$config = array_merge(static::$objectConfig[$class], $config); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (($n = func_num_args()) > 1) { |
|
|
|
@ -394,7 +394,7 @@ class BaseYii
|
|
|
|
|
public static function trace($message, $category = 'application') |
|
|
|
|
{ |
|
|
|
|
if (YII_DEBUG) { |
|
|
|
|
self::$app->getLog()->log($message, Logger::LEVEL_TRACE, $category); |
|
|
|
|
static::$app->getLog()->log($message, Logger::LEVEL_TRACE, $category); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -407,7 +407,7 @@ class BaseYii
|
|
|
|
|
*/ |
|
|
|
|
public static function error($message, $category = 'application') |
|
|
|
|
{ |
|
|
|
|
self::$app->getLog()->log($message, Logger::LEVEL_ERROR, $category); |
|
|
|
|
static::$app->getLog()->log($message, Logger::LEVEL_ERROR, $category); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -419,7 +419,7 @@ class BaseYii
|
|
|
|
|
*/ |
|
|
|
|
public static function warning($message, $category = 'application') |
|
|
|
|
{ |
|
|
|
|
self::$app->getLog()->log($message, Logger::LEVEL_WARNING, $category); |
|
|
|
|
static::$app->getLog()->log($message, Logger::LEVEL_WARNING, $category); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -431,7 +431,7 @@ class BaseYii
|
|
|
|
|
*/ |
|
|
|
|
public static function info($message, $category = 'application') |
|
|
|
|
{ |
|
|
|
|
self::$app->getLog()->log($message, Logger::LEVEL_INFO, $category); |
|
|
|
|
static::$app->getLog()->log($message, Logger::LEVEL_INFO, $category); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -453,7 +453,7 @@ class BaseYii
|
|
|
|
|
*/ |
|
|
|
|
public static function beginProfile($token, $category = 'application') |
|
|
|
|
{ |
|
|
|
|
self::$app->getLog()->log($token, Logger::LEVEL_PROFILE_BEGIN, $category); |
|
|
|
|
static::$app->getLog()->log($token, Logger::LEVEL_PROFILE_BEGIN, $category); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -465,7 +465,7 @@ class BaseYii
|
|
|
|
|
*/ |
|
|
|
|
public static function endProfile($token, $category = 'application') |
|
|
|
|
{ |
|
|
|
|
self::$app->getLog()->log($token, Logger::LEVEL_PROFILE_END, $category); |
|
|
|
|
static::$app->getLog()->log($token, Logger::LEVEL_PROFILE_END, $category); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -504,8 +504,8 @@ class BaseYii
|
|
|
|
|
*/ |
|
|
|
|
public static function t($category, $message, $params = [], $language = null) |
|
|
|
|
{ |
|
|
|
|
if (self::$app !== null) { |
|
|
|
|
return self::$app->getI18n()->translate($category, $message, $params, $language ?: self::$app->language); |
|
|
|
|
if (static::$app !== null) { |
|
|
|
|
return static::$app->getI18n()->translate($category, $message, $params, $language ?: static::$app->language); |
|
|
|
|
} else { |
|
|
|
|
$p = []; |
|
|
|
|
foreach ((array) $params as $name => $value) { |
|
|
|
|