Browse Source

Renamed application to app.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
8b2b7915b4
  1. 13
      framework/YiiBase.php
  2. 4
      framework/base/Application.php
  3. 6
      framework/base/Controller.php
  4. 12
      framework/base/ErrorHandler.php
  5. 12
      framework/base/Module.php
  6. 8
      framework/base/SecurityManager.php
  7. 2
      framework/base/Theme.php
  8. 10
      framework/base/UrlManager.php
  9. 28
      framework/base/View.php
  10. 2
      framework/base/Widget.php
  11. 2
      framework/caching/DbCache.php
  12. 2
      framework/caching/DbDependency.php
  13. 2
      framework/caching/DummyCache.php
  14. 2
      framework/caching/FileCache.php
  15. 4
      framework/console/controllers/HelpController.php
  16. 10
      framework/console/controllers/MigrateController.php
  17. 2
      framework/db/ActiveRecord.php
  18. 2
      framework/db/Command.php
  19. 2
      framework/db/Migration.php
  20. 2
      framework/db/Query.php
  21. 4
      framework/db/Schema.php
  22. 4
      framework/i18n/I18N.php
  23. 2
      framework/i18n/MessageSource.php
  24. 2
      framework/logging/DbTarget.php
  25. 2
      framework/logging/FileTarget.php
  26. 2
      framework/logging/ProfileTarget.php
  27. 2
      framework/logging/Router.php
  28. 2
      framework/logging/Target.php
  29. 2
      framework/logging/WebTarget.php
  30. 4
      framework/util/FileHelper.php
  31. 4
      framework/validators/CaptchaValidator.php
  32. 2
      framework/validators/StringValidator.php
  33. 4
      framework/web/AssetManager.php
  34. 4
      framework/web/Controller.php
  35. 2
      framework/web/Request.php
  36. 2
      framework/web/Sort.php
  37. 2
      framework/web/Theme.php

13
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);
}
}

4
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'] = '';
}

6
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);
}
}

12
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()

12
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, '/'));

8
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;
}

2
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.");
}

10
framework/base/UrlManager.php

@ -112,7 +112,7 @@ use \yii\base\Component;
* </ul>
*
* 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));
}

28
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;

2
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.
*

2
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 {

2
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 {

2
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.
*

2
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'.
*/

4
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);
}

10
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 {

2
framework/db/ActiveRecord.php

@ -96,7 +96,7 @@ class ActiveRecord extends Model
*/
public static function getDb()
{
return \Yii::$application->getDb();
return \Yii::$app->getDb();
}
/**

2
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)) {

2
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');
}
}

2
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);

4
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));
}

4
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 {

2
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;
}
}

2
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 {

2
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);
}

2
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;

2
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 <qiang.xue@gmail.com>

2
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() . ')';
}

2
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)

4
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;

4
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) {

2
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);
}

4
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;

4
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;
}
}

2
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'));
}
}

2
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);
}

2
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;

Loading…
Cancel
Save