diff --git a/framework/YiiBase.php b/framework/YiiBase.php index be59c16..464bcea 100644 --- a/framework/YiiBase.php +++ b/framework/YiiBase.php @@ -65,7 +65,7 @@ class YiiBase /** * @var yii\base\Application the application instance */ - public static $application; + public static $app; /** * @var array registered path aliases * @see getAlias @@ -125,8 +125,8 @@ class YiiBase * * To import a class or a directory, one can use either path alias or class name (can be namespaced): * - * - `@application/components/GoogleMap`: importing the `GoogleMap` class with a path alias; - * - `@application/components/*`: importing the whole `components` directory with a path alias; + * - `@app/components/GoogleMap`: importing the `GoogleMap` class with a path alias; + * - `@app/components/*`: importing the whole `components` directory with a path alias; * - `GoogleMap`: importing the `GoogleMap` class with a class name. [[autoload()]] will be used * when this class is used for the first time. * @@ -262,6 +262,7 @@ class YiiBase * * @param string $className class name * @return boolean whether the class has been loaded successfully + * @throws Exception if the class file does not exist */ public static function autoload($className) { @@ -322,12 +323,12 @@ class YiiBase * the class. For example, * * - `\app\components\GoogleMap`: fully-qualified namespaced class. - * - `@application/components/GoogleMap`: an alias + * - `@app/components/GoogleMap`: an alias * * Below are some usage examples: * * ~~~ - * $object = \Yii::createObject('@application/components/GoogleMap'); + * $object = \Yii::createObject('@app/components/GoogleMap'); * $object = \Yii::createObject(array( * 'class' => '\app\components\GoogleMap', * 'apiKey' => 'xyz', @@ -520,6 +521,6 @@ class YiiBase */ public static function t($message, $params = array(), $language = null) { - Yii::$application->getI18N()->translate($message, $params, $language); + Yii::$app->getI18N()->translate($message, $params, $language); } } diff --git a/framework/base/Application.php b/framework/base/Application.php index e4c1333..9277e70 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -105,7 +105,7 @@ class Application extends Module */ public function __construct($id, $basePath, $config = array()) { - Yii::$application = $this; + Yii::$app = $this; $this->id = $id; $this->setBasePath($basePath); @@ -342,7 +342,7 @@ class Application extends Module */ public function registerDefaultAliases() { - Yii::$aliases['@application'] = $this->getBasePath(); + Yii::$aliases['@app'] = $this->getBasePath(); Yii::$aliases['@entry'] = dirname($_SERVER['SCRIPT_FILENAME']); Yii::$aliases['@www'] = ''; } diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 58deda2..ca3b39b 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -72,9 +72,9 @@ class Controller extends Component * * ~~~ * return array( - * 'action1' => '@application/components/Action1', + * 'action1' => '@app/components/Action1', * 'action2' => array( - * 'class' => '@application/components/Action2', + * 'class' => '@app/components/Action2', * 'property1' => 'value1', * 'property2' => 'value2', * ), @@ -139,7 +139,7 @@ class Controller extends Component } elseif ($pos > 0) { return $this->module->runAction($route, $params); } else { - return \Yii::$application->runAction(ltrim($route, '/'), $params); + return \Yii::$app->runAction(ltrim($route, '/'), $params); } } diff --git a/framework/base/ErrorHandler.php b/framework/base/ErrorHandler.php index 211bad6..9464a92 100644 --- a/framework/base/ErrorHandler.php +++ b/framework/base/ErrorHandler.php @@ -36,7 +36,7 @@ class ErrorHandler extends Component public $discardExistingOutput = true; /** * @var string the route (eg 'site/error') to the controller action that will be used to display external errors. - * Inside the action, it can retrieve the error information by \Yii::$application->errorHandler->error. + * Inside the action, it can retrieve the error information by \Yii::$app->errorHandler->error. * This property defaults to null, meaning ErrorHandler will handle the error display. */ public $errorAction; @@ -71,14 +71,14 @@ class ErrorHandler extends Component protected function render($exception) { if ($this->errorAction !== null) { - \Yii::$application->runAction($this->errorAction); - } elseif (\Yii::$application instanceof \yii\web\Application) { + \Yii::$app->runAction($this->errorAction); + } elseif (\Yii::$app instanceof \yii\web\Application) { if (!headers_sent()) { $errorCode = $exception instanceof HttpException ? $exception->statusCode : 500; header("HTTP/1.0 $errorCode " . get_class($exception)); } if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') { - \Yii::$application->renderException($exception); + \Yii::$app->renderException($exception); } else { $view = new View($this); if (!YII_DEBUG || $exception instanceof UserException) { @@ -91,7 +91,7 @@ class ErrorHandler extends Component )); } } else { - \Yii::$application->renderException($exception); + \Yii::$app->renderException($exception); } } @@ -239,7 +239,7 @@ class ErrorHandler extends Component public function htmlEncode($text) { - return htmlspecialchars($text, ENT_QUOTES, \Yii::$application->charset); + return htmlspecialchars($text, ENT_QUOTES, \Yii::$app->charset); } public function clearOutput() diff --git a/framework/base/Module.php b/framework/base/Module.php index dcb468c..3217471 100644 --- a/framework/base/Module.php +++ b/framework/base/Module.php @@ -73,9 +73,9 @@ abstract class Module extends Component * * ~~~ * array( - * 'account' => '@application/controllers/UserController', + * 'account' => '@app/controllers/UserController', * 'article' => array( - * 'class' => '@application/controllers/PostController', + * 'class' => '@app/controllers/PostController', * 'pageTitle' => 'something new', * ), * ) @@ -311,7 +311,7 @@ abstract class Module extends Component * * ~~~ * array( - * '@models' => '@application/models', // an existing alias + * '@models' => '@app/models', // an existing alias * '@backend' => __DIR__ . '/../backend', // a directory * ) * ~~~ @@ -563,10 +563,10 @@ abstract class Module extends Component if (is_array($result)) { /** @var $controller Controller */ list($controller, $actionID) = $result; - $oldController = Yii::$application->controller; - Yii::$application->controller = $controller; + $oldController = Yii::$app->controller; + Yii::$app->controller = $controller; $status = $controller->runAction($actionID, $params); - Yii::$application->controller = $oldController; + Yii::$app->controller = $oldController; return $status; } else { throw new InvalidRouteException('Unable to resolve the request: ' . trim($this->getUniqueId() . '/' . $route, '/')); diff --git a/framework/base/SecurityManager.php b/framework/base/SecurityManager.php index a3fb654..18ccb03 100644 --- a/framework/base/SecurityManager.php +++ b/framework/base/SecurityManager.php @@ -59,12 +59,12 @@ class SecurityManager extends Component if ($this->_validationKey !== null) { return $this->_validationKey; } else { - if (($key = \Yii::$application->getGlobalState(self::STATE_VALIDATION_KEY)) !== null) { + if (($key = \Yii::$app->getGlobalState(self::STATE_VALIDATION_KEY)) !== null) { $this->setValidationKey($key); } else { $key = $this->generateRandomKey(); $this->setValidationKey($key); - \Yii::$application->setGlobalState(self::STATE_VALIDATION_KEY, $key); + \Yii::$app->setGlobalState(self::STATE_VALIDATION_KEY, $key); } return $this->_validationKey; } @@ -92,12 +92,12 @@ class SecurityManager extends Component if ($this->_encryptionKey !== null) { return $this->_encryptionKey; } else { - if (($key = \Yii::$application->getGlobalState(self::STATE_ENCRYPTION_KEY)) !== null) { + if (($key = \Yii::$app->getGlobalState(self::STATE_ENCRYPTION_KEY)) !== null) { $this->setEncryptionKey($key); } else { $key = $this->generateRandomKey(); $this->setEncryptionKey($key); - \Yii::$application->setGlobalState(self::STATE_ENCRYPTION_KEY, $key); + \Yii::$app->setGlobalState(self::STATE_ENCRYPTION_KEY, $key); } return $this->_encryptionKey; } diff --git a/framework/base/Theme.php b/framework/base/Theme.php index 03f8f55..52d5245 100644 --- a/framework/base/Theme.php +++ b/framework/base/Theme.php @@ -58,7 +58,7 @@ class Theme extends Component if (empty($this->pathMap)) { if ($this->basePath !== null) { $this->basePath = FileHelper::ensureDirectory($this->basePath); - $this->pathMap = array(Yii::$application->getBasePath() => $this->basePath); + $this->pathMap = array(Yii::$app->getBasePath() => $this->basePath); } else { throw new InvalidConfigException("Theme::basePath must be set."); } diff --git a/framework/base/UrlManager.php b/framework/base/UrlManager.php index db6b598..e17685d 100644 --- a/framework/base/UrlManager.php +++ b/framework/base/UrlManager.php @@ -112,7 +112,7 @@ use \yii\base\Component; * * * UrlManager is a default application component that may be accessed via - * {@link \Yii::$application->urlManager}. + * {@link \Yii::$app->urlManager}. * * @property string $baseUrl The base URL of the application (the part after host name and before query string). * If {@link showScriptName} is true, it will include the script name part. @@ -214,7 +214,7 @@ class UrlManager extends Component { if(empty($this->rules) || $this->getUrlFormat()===self::GET_FORMAT) return; - if($this->cacheID!==false && ($cache=\Yii::$application->getComponent($this->cacheID))!==null) + if($this->cacheID!==false && ($cache=\Yii::$app->getComponent($this->cacheID))!==null) { $hash=md5(serialize($this->rules)); if(($data=$cache->get(self::CACHE_KEY))!==false && isset($data[1]) && $data[1]===$hash) @@ -464,9 +464,9 @@ class UrlManager extends Component else { if($this->showScriptName) - $this->_baseUrl=\Yii::$application->getRequest()->getScriptUrl(); + $this->_baseUrl=\Yii::$app->getRequest()->getScriptUrl(); else - $this->_baseUrl=\Yii::$application->getRequest()->getBaseUrl(); + $this->_baseUrl=\Yii::$app->getRequest()->getBaseUrl(); return $this->_baseUrl; } } @@ -755,7 +755,7 @@ class CUrlRule extends CBaseUrlRule if($this->hasHostInfo) { - $hostInfo=\Yii::$application->getRequest()->getHostInfo(); + $hostInfo=\Yii::$app->getRequest()->getHostInfo(); if(stripos($url,$hostInfo)===0) $url=substr($url,strlen($hostInfo)); } diff --git a/framework/base/View.php b/framework/base/View.php index 410e3c5..9caa4ef 100644 --- a/framework/base/View.php +++ b/framework/base/View.php @@ -148,7 +148,7 @@ class View extends Component */ public function renderFile($file, $params = array()) { - $renderer = Yii::$application->getViewRenderer(); + $renderer = Yii::$app->getViewRenderer(); if ($renderer !== null) { return $renderer->render($this, $file, $params); } else { @@ -344,7 +344,7 @@ class View extends Component * * A view name can be specified in one of the following formats: * - * - path alias (e.g. "@application/views/site/index"); + * - path alias (e.g. "@app/views/site/index"); * - absolute path within application (e.g. "//site/index"): the view name starts with double slashes. * The actual view file will be looked for under the [[Application::viewPath|view path]] of the application. * - absolute path within module (e.g. "/site/index"): the view name starts with a single slash. @@ -374,7 +374,7 @@ class View extends Component $view .= '.php'; } if (strncmp($view, '@', 1) === 0) { - // e.g. "@application/views/common" + // e.g. "@app/views/common" if (($file = Yii::getAlias($view)) === false) { throw new InvalidConfigException("Invalid path alias: $view"); } @@ -386,18 +386,18 @@ class View extends Component $class = new \ReflectionClass($this->owner); $file = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $view; } else { - $file = Yii::$application->getViewPath() . DIRECTORY_SEPARATOR . $view; + $file = Yii::$app->getViewPath() . DIRECTORY_SEPARATOR . $view; } - } elseif (strncmp($view, '//', 2) !== 0 && Yii::$application->controller !== null) { + } elseif (strncmp($view, '//', 2) !== 0 && Yii::$app->controller !== null) { // e.g. "/site/index" - $file = Yii::$application->controller->module->getViewPath() . DIRECTORY_SEPARATOR . ltrim($view, '/'); + $file = Yii::$app->controller->module->getViewPath() . DIRECTORY_SEPARATOR . ltrim($view, '/'); } else { // e.g. "//layouts/main" - $file = Yii::$application->getViewPath() . DIRECTORY_SEPARATOR . ltrim($view, '/'); + $file = Yii::$app->getViewPath() . DIRECTORY_SEPARATOR . ltrim($view, '/'); } if (is_file($file)) { - if ($this->enableTheme && ($theme = Yii::$application->getTheme()) !== null) { + if ($this->enableTheme && ($theme = Yii::$app->getTheme()) !== null) { $file = $theme->apply($file); } return $this->enableI18N ? FileHelper::localize($file, $this->language, $this->sourceLanguage) : $file; @@ -423,7 +423,7 @@ class View extends Component * * Like view names, a layout name can take several formats: * - * - path alias (e.g. "@application/views/layouts/main"); + * - path alias (e.g. "@app/views/layouts/main"); * - absolute path (e.g. "/main"): the layout name starts with a slash. The actual layout file will be * looked for under the [[Application::layoutPath|layout path]] of the application; * - relative path (e.g. "main"): the actual layout layout file will be looked for under the @@ -444,10 +444,10 @@ class View extends Component { /** @var $module Module */ if (is_string($this->layout)) { - if (Yii::$application->controller) { - $module = Yii::$application->controller->module; + if (Yii::$app->controller) { + $module = Yii::$app->controller->module; } else { - $module = Yii::$application; + $module = Yii::$app; } $view = $this->layout; } elseif ($this->owner instanceof Controller) { @@ -477,13 +477,13 @@ class View extends Component throw new InvalidConfigException("Invalid path alias: $view"); } } elseif (strncmp($view, '/', 1) === 0) { - $file = Yii::$application->getLayoutPath() . DIRECTORY_SEPARATOR . $view; + $file = Yii::$app->getLayoutPath() . DIRECTORY_SEPARATOR . $view; } else { $file = $module->getLayoutPath() . DIRECTORY_SEPARATOR . $view; } if (is_file($file)) { - if ($this->enableTheme && ($theme = Yii::$application->getTheme()) !== null) { + if ($this->enableTheme && ($theme = Yii::$app->getTheme()) !== null) { $file = $theme->apply($file); } return $this->enableI18N ? FileHelper::localize($file, $this->language, $this->sourceLanguage) : $file; diff --git a/framework/base/Widget.php b/framework/base/Widget.php index bdec634..b494387 100644 --- a/framework/base/Widget.php +++ b/framework/base/Widget.php @@ -80,7 +80,7 @@ class Widget extends Component * To determine which view file should be rendered, the method calls [[findViewFile()]] which * will search in the directories as specified by [[basePath]]. * - * View name can be a path alias representing an absolute file path (e.g. `@application/views/layout/index`), + * View name can be a path alias representing an absolute file path (e.g. `@app/views/layout/index`), * or a path relative to [[basePath]]. The file suffix is optional and defaults to `.php` if not given * in the view name. * diff --git a/framework/caching/DbCache.php b/framework/caching/DbCache.php index 4b84bfd..75f13b0 100644 --- a/framework/caching/DbCache.php +++ b/framework/caching/DbCache.php @@ -74,7 +74,7 @@ class DbCache extends Cache public function getDb() { if ($this->_db === null) { - $db = \Yii::$application->getComponent($this->connectionID); + $db = \Yii::$app->getComponent($this->connectionID); if ($db instanceof Connection) { $this->_db = $db; } else { diff --git a/framework/caching/DbDependency.php b/framework/caching/DbDependency.php index 7ffdb4e..e4cb547 100644 --- a/framework/caching/DbDependency.php +++ b/framework/caching/DbDependency.php @@ -91,7 +91,7 @@ class DbDependency extends Dependency public function getDb() { if ($this->_db === null) { - $db = \Yii::$application->getComponent($this->connectionID); + $db = \Yii::$app->getComponent($this->connectionID); if ($db instanceof Connection) { $this->_db = $db; } else { diff --git a/framework/caching/DummyCache.php b/framework/caching/DummyCache.php index f6e8a44..1f7a0c5 100644 --- a/framework/caching/DummyCache.php +++ b/framework/caching/DummyCache.php @@ -13,7 +13,7 @@ namespace yii\caching; * DummyCache is a placeholder cache component. * * DummyCache does not cache anything. It is provided so that one can always configure - * a 'cache' application component and save the check of existence of `\Yii::$application->cache`. + * a 'cache' application component and save the check of existence of `\Yii::$app->cache`. * By replacing DummyCache with some other cache component, one can quickly switch from * non-caching mode to caching mode. * diff --git a/framework/caching/FileCache.php b/framework/caching/FileCache.php index f97861f..bf46fb6 100644 --- a/framework/caching/FileCache.php +++ b/framework/caching/FileCache.php @@ -28,7 +28,7 @@ class FileCache extends Cache /** * @var string the directory to store cache files. You may use path alias here. */ - public $cachePath = '@application/runtime/cache'; + public $cachePath = '@app/runtime/cache'; /** * @var string cache file suffix. Defaults to '.bin'. */ diff --git a/framework/console/controllers/HelpController.php b/framework/console/controllers/HelpController.php index 4a37f3d..5ad3bbc 100644 --- a/framework/console/controllers/HelpController.php +++ b/framework/console/controllers/HelpController.php @@ -55,7 +55,7 @@ class HelpController extends Controller public function actionIndex($command = null) { if ($command !== null) { - $result = Yii::$application->createController($command); + $result = Yii::$app->createController($command); if ($result === false) { throw new Exception(Yii::t('yii|No help for unknown command "{command}".', array( '{command}' => $command, @@ -81,7 +81,7 @@ class HelpController extends Controller */ public function getCommands() { - $commands = $this->getModuleCommands(Yii::$application); + $commands = $this->getModuleCommands(Yii::$app); sort($commands); return array_unique($commands); } diff --git a/framework/console/controllers/MigrateController.php b/framework/console/controllers/MigrateController.php index 62e7d40..0f05d61 100644 --- a/framework/console/controllers/MigrateController.php +++ b/framework/console/controllers/MigrateController.php @@ -70,7 +70,7 @@ class MigrateController extends Controller * @var string the directory storing the migration classes. This can be either * a path alias or a directory. */ - public $migrationPath = '@application/migrations'; + public $migrationPath = '@app/migrations'; /** * @var string the name of the table for keeping applied migration information. */ @@ -82,7 +82,7 @@ class MigrateController extends Controller public $connectionID = 'db'; /** * @var string the template file for generating new migrations. - * This can be either a path alias (e.g. "@application/migrations/template.php") + * This can be either a path alias (e.g. "@app/migrations/template.php") * or a file path. */ public $templateFile = '@yii/views/migration.php'; @@ -121,7 +121,7 @@ class MigrateController extends Controller } $this->migrationPath = $path; - $this->db = Yii::$application->getComponent($this->connectionID); + $this->db = Yii::$app->getComponent($this->connectionID); if (!$this->db instanceof Connection) { throw new Exception("Invalid DB connection \"{$this->connectionID}\"."); } @@ -150,7 +150,7 @@ class MigrateController extends Controller { if (($migrations = $this->getNewMigrations()) === array()) { echo "No new migration found. Your system is up-to-date.\n"; - Yii::$application->end(); + Yii::$app->end(); } $total = count($migrations); @@ -576,7 +576,7 @@ class MigrateController extends Controller if ($this->db !== null) { return $this->db; } else { - $this->db = Yii::$application->getComponent($this->connectionID); + $this->db = Yii::$app->getComponent($this->connectionID); if ($this->db instanceof Connection) { return $this->db; } else { diff --git a/framework/db/ActiveRecord.php b/framework/db/ActiveRecord.php index c6d3d81..0b2451f 100644 --- a/framework/db/ActiveRecord.php +++ b/framework/db/ActiveRecord.php @@ -96,7 +96,7 @@ class ActiveRecord extends Model */ public static function getDb() { - return \Yii::$application->getDb(); + return \Yii::$app->getDb(); } /** diff --git a/framework/db/Command.php b/framework/db/Command.php index f893c8c..bb68f33 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -387,7 +387,7 @@ class Command extends \yii\base\Component /** @var $cache \yii\caching\Cache */ if ($db->enableQueryCache && $method !== '') { - $cache = \Yii::$application->getComponent($db->queryCacheID); + $cache = \Yii::$app->getComponent($db->queryCacheID); } if (isset($cache)) { diff --git a/framework/db/Migration.php b/framework/db/Migration.php index 6dbaa78..c12da29 100644 --- a/framework/db/Migration.php +++ b/framework/db/Migration.php @@ -51,7 +51,7 @@ class Migration extends \yii\base\Component { parent::init(); if ($this->db === null) { - $this->db = \Yii::$application->getComponent('db'); + $this->db = \Yii::$app->getComponent('db'); } } diff --git a/framework/db/Query.php b/framework/db/Query.php index 10bba08..ffc6206 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -117,7 +117,7 @@ class Query extends \yii\base\Component public function createCommand($db = null) { if ($db === null) { - $db = \Yii::$application->db; + $db = \Yii::$app->db; } $sql = $db->getQueryBuilder()->build($this); return $db->createCommand($sql, $this->params); diff --git a/framework/db/Schema.php b/framework/db/Schema.php index 7415bee..6306776 100644 --- a/framework/db/Schema.php +++ b/framework/db/Schema.php @@ -87,7 +87,7 @@ abstract class Schema extends \yii\base\Object $realName = $this->getRealTableName($name); /** @var $cache Cache */ - if ($db->enableSchemaCache && ($cache = \Yii::$application->getComponent($db->schemaCacheID)) !== null && !in_array($name, $db->schemaCacheExclude, true)) { + if ($db->enableSchemaCache && ($cache = \Yii::$app->getComponent($db->schemaCacheID)) !== null && !in_array($name, $db->schemaCacheExclude, true)) { $key = $this->getCacheKey($cache, $name); if ($refresh || ($table = $cache->get($key)) === false) { $table = $this->loadTableSchema($realName); @@ -171,7 +171,7 @@ abstract class Schema extends \yii\base\Object public function refresh() { /** @var $cache \yii\caching\Cache */ - if ($this->db->enableSchemaCache && ($cache = \Yii::$application->getComponent($this->db->schemaCacheID)) !== null) { + if ($this->db->enableSchemaCache && ($cache = \Yii::$app->getComponent($this->db->schemaCacheID)) !== null) { foreach ($this->_tables as $name => $table) { $cache->delete($this->getCacheKey($cache, $name)); } diff --git a/framework/i18n/I18N.php b/framework/i18n/I18N.php index fe09a84..42b7e07 100644 --- a/framework/i18n/I18N.php +++ b/framework/i18n/I18N.php @@ -10,10 +10,10 @@ class I18N extends Component public function translate($message, $params = array(), $language = null) { if ($language === null) { - $language = Yii::$application->language; + $language = Yii::$app->language; } - if (preg_match('/^([\w\-\.]+)\|(.*)/', $message, $matches)) { + if (strpos($message, '|') !== false && preg_match('/^([\w\-\.]+)\|(.*)/', $message, $matches)) { $category = $matches[1]; $message = $matches[2]; } else { diff --git a/framework/i18n/MessageSource.php b/framework/i18n/MessageSource.php index 4f6bf94..e1df935 100644 --- a/framework/i18n/MessageSource.php +++ b/framework/i18n/MessageSource.php @@ -49,7 +49,7 @@ class MessageSource extends Component { parent::init(); if ($this->sourceLanguage === null) { - $this->sourceLanguage = Yii::$application->sourceLanguage; + $this->sourceLanguage = Yii::$app->sourceLanguage; } } diff --git a/framework/logging/DbTarget.php b/framework/logging/DbTarget.php index 129e4d4..8f38eb8 100644 --- a/framework/logging/DbTarget.php +++ b/framework/logging/DbTarget.php @@ -69,7 +69,7 @@ class DbTarget extends Target public function getDb() { if ($this->_db === null) { - $db = \Yii::$application->getComponent($this->connectionID); + $db = \Yii::$app->getComponent($this->connectionID); if ($db instanceof Connection) { $this->_db = $db; } else { diff --git a/framework/logging/FileTarget.php b/framework/logging/FileTarget.php index 0eb897e..e2dd56b 100644 --- a/framework/logging/FileTarget.php +++ b/framework/logging/FileTarget.php @@ -48,7 +48,7 @@ class FileTarget extends Target { parent::init(); if ($this->logFile === null) { - $this->logFile = \Yii::$application->getRuntimePath() . DIRECTORY_SEPARATOR . 'application.log'; + $this->logFile = \Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'application.log'; } else { $this->logFile = \Yii::getAlias($this->logFile); } diff --git a/framework/logging/ProfileTarget.php b/framework/logging/ProfileTarget.php index 6030669..d80ec18 100644 --- a/framework/logging/ProfileTarget.php +++ b/framework/logging/ProfileTarget.php @@ -71,7 +71,7 @@ class CProfileLogRoute extends CWebLogRoute */ public function processLogs($logs) { - $app = \Yii::$application; + $app = \Yii::$app; if (!($app instanceof CWebApplication) || $app->getRequest()->getIsAjaxRequest()) return; diff --git a/framework/logging/Router.php b/framework/logging/Router.php index 2e6a8dd..1e1f16c 100644 --- a/framework/logging/Router.php +++ b/framework/logging/Router.php @@ -52,7 +52,7 @@ use yii\base\Application; * as follows: * * ~~~ - * Yii::$application->log->targets['file']->enabled = false; + * Yii::$app->log->targets['file']->enabled = false; * ~~~ * * @author Qiang Xue diff --git a/framework/logging/Target.php b/framework/logging/Target.php index c9e175a..a75a512 100644 --- a/framework/logging/Target.php +++ b/framework/logging/Target.php @@ -110,7 +110,7 @@ abstract class Target extends \yii\base\Component protected function getContextMessage() { $context = array(); - if ($this->logUser && ($user = \Yii::$application->getComponent('user', false)) !== null) { + if ($this->logUser && ($user = \Yii::$app->getComponent('user', false)) !== null) { $context[] = 'User: ' . $user->getName() . ' (ID: ' . $user->getId() . ')'; } diff --git a/framework/logging/WebTarget.php b/framework/logging/WebTarget.php index 6ce8ea0..7198b3a 100644 --- a/framework/logging/WebTarget.php +++ b/framework/logging/WebTarget.php @@ -46,7 +46,7 @@ class CWebLogRoute extends CLogRoute */ protected function render($view, $data) { - $app = \Yii::$application; + $app = \Yii::$app; $isAjax = $app->getRequest()->getIsAjaxRequest(); if ($this->showInFireBug) diff --git a/framework/util/FileHelper.php b/framework/util/FileHelper.php index c65e4f0..6565c77 100644 --- a/framework/util/FileHelper.php +++ b/framework/util/FileHelper.php @@ -91,10 +91,10 @@ class FileHelper public static function localize($file, $language = null, $sourceLanguage = null) { if ($language === null) { - $language = \Yii::$application->getLanguage(); + $language = \Yii::$app->getLanguage(); } if ($sourceLanguage === null) { - $sourceLanguage = \Yii::$application->sourceLanguage; + $sourceLanguage = \Yii::$app->sourceLanguage; } if ($language === $sourceLanguage) { return $file; diff --git a/framework/validators/CaptchaValidator.php b/framework/validators/CaptchaValidator.php index 1b6c303..2303333 100644 --- a/framework/validators/CaptchaValidator.php +++ b/framework/validators/CaptchaValidator.php @@ -61,13 +61,13 @@ class CaptchaValidator extends Validator public function getCaptchaAction() { if (strpos($this->captchaAction, '/') !== false) { // contains controller or module - $ca = \Yii::$application->createController($this->captchaAction); + $ca = \Yii::$app->createController($this->captchaAction); if ($ca !== null) { list($controller, $actionID) = $ca; $action = $controller->createAction($actionID); } } else { - $action = \Yii::$application->getController()->createAction($this->captchaAction); + $action = \Yii::$app->getController()->createAction($this->captchaAction); } if ($action === null) { diff --git a/framework/validators/StringValidator.php b/framework/validators/StringValidator.php index c57e183..b39abb8 100644 --- a/framework/validators/StringValidator.php +++ b/framework/validators/StringValidator.php @@ -82,7 +82,7 @@ class StringValidator extends Validator } if (function_exists('mb_strlen') && $this->encoding !== false) { - $length = mb_strlen($value, $this->encoding ? $this->encoding : \Yii::$application->charset); + $length = mb_strlen($value, $this->encoding ? $this->encoding : \Yii::$app->charset); } else { $length = strlen($value); } diff --git a/framework/web/AssetManager.php b/framework/web/AssetManager.php index 1c5965a..0d3248b 100644 --- a/framework/web/AssetManager.php +++ b/framework/web/AssetManager.php @@ -97,7 +97,7 @@ class CAssetManager extends CApplicationComponent { if($this->_basePath===null) { - $request=\Yii::$application->getRequest(); + $request=\Yii::$app->getRequest(); $this->setBasePath(dirname($request->getScriptFile()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH); } return $this->_basePath; @@ -125,7 +125,7 @@ class CAssetManager extends CApplicationComponent { if($this->_baseUrl===null) { - $request=\Yii::$application->getRequest(); + $request=\Yii::$app->getRequest(); $this->setBaseUrl($request->getBaseUrl().'/'.self::DEFAULT_BASEPATH); } return $this->_baseUrl; diff --git a/framework/web/Controller.php b/framework/web/Controller.php index 6c0bc28..22cb8e7 100644 --- a/framework/web/Controller.php +++ b/framework/web/Controller.php @@ -59,9 +59,9 @@ class Controller extends \yii\base\Controller else { $name = ucfirst(basename($this->id)); if($this->action!==null && strcasecmp($this->action->id,$this->defaultAction)) - return $this->_pageTitle=\Yii::$application->name.' - '.ucfirst($this->action->id).' '.$name; + return $this->_pageTitle=\Yii::$app->name.' - '.ucfirst($this->action->id).' '.$name; else - return $this->_pageTitle=\Yii::$application->name.' - '.$name; + return $this->_pageTitle=\Yii::$app->name.' - '.$name; } } diff --git a/framework/web/Request.php b/framework/web/Request.php index 68d6044..8337382 100644 --- a/framework/web/Request.php +++ b/framework/web/Request.php @@ -87,7 +87,7 @@ class Request extends \yii\base\Request } if ($this->enableCsrfValidation) { - \Yii::$application->on('beginRequest', array($this, 'validateCsrfToken')); + \Yii::$app->on('beginRequest', array($this, 'validateCsrfToken')); } } diff --git a/framework/web/Sort.php b/framework/web/Sort.php index 12e16a5..6b128e7 100644 --- a/framework/web/Sort.php +++ b/framework/web/Sort.php @@ -307,7 +307,7 @@ class CSort extends CComponent $directions = array($attribute => $descending); } - $url = $this->createUrl(\Yii::$application->getController(), $directions); + $url = $this->createUrl(\Yii::$app->getController(), $directions); return $this->createLink($attribute, $label, $url, $htmlOptions); } diff --git a/framework/web/Theme.php b/framework/web/Theme.php index 5dcd601..22fe608 100644 --- a/framework/web/Theme.php +++ b/framework/web/Theme.php @@ -126,7 +126,7 @@ class CTheme extends CComponent $module=$module->getParentModule(); } if($module===null) - $layoutName=\Yii::$application->layout; + $layoutName=\Yii::$app->layout; else { $layoutName=$module->layout;