Commit 88d38b78 by Qiang Xue

Fixes #4501: Renamed the constant `YII_PATH` to `YII2_PATH`

parent c6c29db9
......@@ -23,17 +23,17 @@ class ClassmapController extends Controller
/**
* Creates a class map for the core Yii classes.
* @param string $root the root path of Yii framework. Defaults to YII_PATH.
* @param string $mapFile the file to contain the class map. Defaults to YII_PATH . '/classes.php'.
* @param string $root the root path of Yii framework. Defaults to YII2_PATH.
* @param string $mapFile the file to contain the class map. Defaults to YII2_PATH . '/classes.php'.
*/
public function actionCreate($root = null, $mapFile = null)
{
if ($root === null) {
$root = YII_PATH;
$root = YII2_PATH;
}
$root = FileHelper::normalizePath($root);
if ($mapFile === null) {
$mapFile = YII_PATH . '/classes.php';
$mapFile = YII2_PATH . '/classes.php';
}
$options = [
'filter' => function ($path) {
......@@ -60,7 +60,7 @@ class ClassmapController extends Controller
throw new Exception("Something wrong: $file\n");
}
$path = str_replace('\\', '/', substr($file, strlen($root)));
$map[$path] = " 'yii" . substr(str_replace('/', '\\', $path), 0, -4) . "' => YII_PATH . '$path',";
$map[$path] = " 'yii" . substr(str_replace('/', '\\', $path), 0, -4) . "' => YII2_PATH . '$path',";
}
ksort($map);
$map = implode("\n", $map);
......
......@@ -37,7 +37,7 @@ class PhpDocController extends Controller
*
* See https://github.com/yiisoft/yii2/wiki/Core-framework-code-style#documentation for details.
*
* @param string $root the directory to parse files from. Defaults to YII_PATH.
* @param string $root the directory to parse files from. Defaults to YII2_PATH.
*/
public function actionProperty($root = null)
{
......@@ -68,7 +68,7 @@ class PhpDocController extends Controller
/**
* Fix some issues with PHPdoc in files
*
* @param string $root the directory to parse files from. Defaults to YII_PATH.
* @param string $root the directory to parse files from. Defaults to YII2_PATH.
*/
public function actionFix($root = null)
{
......@@ -112,7 +112,7 @@ class PhpDocController extends Controller
{
$except = [];
if ($root === null) {
$root = dirname(YII_PATH);
$root = dirname(YII2_PATH);
$extensionPath = "$root/extensions";
foreach (scandir($extensionPath) as $extension) {
if (ctype_alpha($extension) && is_dir($extensionPath . '/' . $extension)) {
......
......@@ -79,7 +79,7 @@ class ReleaseController extends Controller
protected function getChangelogs()
{
return array_merge([YII_PATH . '/CHANGELOG.md'], glob(dirname(YII_PATH) . '/extensions/*/CHANGELOG.md'));
return array_merge([YII2_PATH . '/CHANGELOG.md'], glob(dirname(YII2_PATH) . '/extensions/*/CHANGELOG.md'));
}
protected function composerSetStability($version)
......@@ -99,9 +99,9 @@ class ReleaseController extends Controller
'/"minimum-stability": "(.+?)",/',
'"minimum-stability": "' . $stability . '",',
[
dirname(YII_PATH) . '/apps/advanced/composer.json',
dirname(YII_PATH) . '/apps/basic/composer.json',
dirname(YII_PATH) . '/apps/benchmark/composer.json',
dirname(YII2_PATH) . '/apps/advanced/composer.json',
dirname(YII2_PATH) . '/apps/basic/composer.json',
dirname(YII2_PATH) . '/apps/benchmark/composer.json',
]
);
}
......@@ -111,7 +111,7 @@ class ReleaseController extends Controller
$this->sed(
'/function getVersion\(\)\n \{\n return \'(.+?)\';/',
"function getVersion()\n {\n return '$version';",
YII_PATH . '/BaseYii.php');
YII2_PATH . '/BaseYii.php');
}
protected function sed($pattern, $replace, $files)
......
......@@ -121,7 +121,7 @@ class BaseDoc extends Object
//
// public function getSourceCode()
// {
// $lines = file(YII_PATH . $this->sourcePath);
// $lines = file(YII2_PATH . $this->sourcePath);
// return implode("", array_slice($lines, $this->startLine - 1, $this->endLine - $this->startLine + 1));
// }
......
......@@ -20,7 +20,7 @@ defined('YII_BEGIN_TIME') or define('YII_BEGIN_TIME', microtime(true));
/**
* This constant defines the framework installation directory.
*/
defined('YII_PATH') or define('YII_PATH', __DIR__);
defined('YII2_PATH') or define('YII2_PATH', __DIR__);
/**
* This constant defines whether the application should be in debug mode or not. Defaults to false.
*/
......
......@@ -229,6 +229,7 @@ Yii Framework 2 Change Log
- Chg #4310: Removed `$data` from signature of `yii\rbac\ManagerInterface` (samdark)
- Chg #4318: `yii\helpers\Html::ul()` and `ol()` will return an empty list tag if an empty item array is given (qiangxue)
- Chg #4331: `yii\helpers\Url` now uses `UrlManager` to determine base URL when generating URLs (qiangxue)
- Chg #4501: Renamed the constant `YII_PATH` to `YII2_PATH` (qiangxue)
- Chg #4586: Signed bigint and unsigned int will be converted into integers when they are loaded from DB by AR (qiangxue)
- Chg #4591: `yii\helpers\Url::to()` will no longer prefix relative URLs with the base URL (qiangxue)
- Chg #4595: `yii\widgets\LinkPager`'s `nextPageLabel`, `prevPageLabel`, `firstPageLabel`, `lastPageLabel` are now taking `false` instead of `null` for "no label" (samdark)
......
......@@ -78,6 +78,8 @@ Upgrade from Yii 2.0 Beta
`new \yii\caching\TagDependency(['tags' => 'TagName'])`, where `TagName` is similar to the group name that you
previously used.
* If you are using the constant `YII_PATH` in your code, you should rename it to `YII2_PATH` now.
* You must explicitly configure `yii\web\Request::cookieValidationKey` with a secret key. Previously this is done automatically.
To do so, modify your application configuration like the following:
......
......@@ -141,7 +141,7 @@ class Logger extends Component
$ts = debug_backtrace();
array_pop($ts); // remove the last trace since it would be the entry script, not very useful
foreach ($ts as $trace) {
if (isset($trace['file'], $trace['line']) && strpos($trace['file'], YII_PATH) !== 0) {
if (isset($trace['file'], $trace['line']) && strpos($trace['file'], YII2_PATH) !== 0) {
unset($trace['object'], $trace['args']);
$traces[] = $trace;
if (++$count >= $this->traceLevel) {
......
......@@ -278,7 +278,7 @@ class ErrorHandler extends \yii\base\ErrorHandler
*/
public function isCoreFile($file)
{
return $file === null || strpos(realpath($file), YII_PATH . DIRECTORY_SEPARATOR) === 0;
return $file === null || strpos(realpath($file), YII2_PATH . DIRECTORY_SEPARATOR) === 0;
}
/**
......
......@@ -26,7 +26,7 @@ class BaseYiiTest extends TestCase
public function testAlias()
{
$this->assertEquals(YII_PATH, Yii::getAlias('@yii'));
$this->assertEquals(YII2_PATH, Yii::getAlias('@yii'));
Yii::$aliases = [];
$this->assertFalse(Yii::getAlias('@yii', false));
......
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