Commit e4452581 by Alexander Makarov

Revert "Fixes #3760: Gii model generator now imports classes when necessary…

Revert "Fixes #3760: Gii model generator now imports classes when necessary instead of using fully qualified class names" This reverts commit 0c8faedd.
parent e5d7d038
......@@ -4,7 +4,6 @@ Yii Framework 2 gii extension Change Log
2.0.1 under development
-----------------------
- Enh #3760: Gii model generator now imports classes when necessary instead of using fully qualified class names (umneeq, samdark)
- Enh #5613: Added `--overwrite` option to Gii console command to support overwriting all files (motin, qiangxue)
- Bug: Gii console command help information does not contain global options (qiangxue)
......
......@@ -165,17 +165,9 @@ class Generator extends \yii\gii\Generator
foreach ($this->getTableNames() as $tableName) {
$className = $this->generateClassName($tableName);
$tableSchema = $db->getTableSchema($tableName);
$baseClassReflection = new \ReflectionClass($this->baseClass);
$baseClassName = $baseClassReflection->getShortName();
$baseClassNamespace = '\\' . ltrim($baseClassReflection->getNamespaceName(), '\\');
$params = [
'tableName' => $tableName,
'className' => $className,
'classNamespace' => '\\' . ltrim($this->ns, '\\'),
'baseClassName' => $baseClassName,
'baseClassNamespace' => $baseClassNamespace,
'tableSchema' => $tableSchema,
'labels' => $this->generateLabels($tableSchema),
'rules' => $this->generateRules($tableSchema),
......
......@@ -7,9 +7,6 @@
/* @var $generator yii\gii\generators\model\Generator */
/* @var $tableName string full table name */
/* @var $className string class name */
/* @var $classNamespace string class fully qualified namespace */
/* @var $baseClassName string base class name */
/* @var $baseClassNamespace string base class fully qualified namespace */
/* @var $tableSchema yii\db\TableSchema */
/* @var $labels string[] list of attribute labels (name => label) */
/* @var $rules string[] list of validation rules */
......@@ -21,9 +18,6 @@ echo "<?php\n";
namespace <?= $generator->ns ?>;
use Yii;
<?php if ($classNamespace !== $baseClassNamespace): ?>
use <?= ltrim($generator->baseClass, '\\') ?><?= $className === $baseClassName ? ' as ' . $baseClassName . 'Base' : '' ?>;
<?php endif; ?>
/**
* This is the model class for table "<?= $generator->generateTableName($tableName) ?>".
......@@ -38,7 +32,7 @@ use <?= ltrim($generator->baseClass, '\\') ?><?= $className === $baseClassName ?
<?php endforeach; ?>
<?php endif; ?>
*/
class <?= $className ?> extends <?= ($className === $baseClassName ? $baseClassName . 'Base' : $baseClassName) . "\n" ?>
class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') . "\n" ?>
{
/**
* @inheritdoc
......
......@@ -14,7 +14,6 @@ Yii Framework 2 Change Log
- Bug #5682: The `asset` command would incorrectly combine CSS files when `UrlManager::linkAssets` is true (dmvslv)
- Bug #5702: Parenthesis should be automatically added to `Validator::whenClient` to avoid js error (mdmunir, qiangxue)
- Bug: Gii console command help information does not contain global options (qiangxue)
- Enh #3760: Gii model generator now imports classes when necessary instead of using fully qualified class names (umneeq, samdark)
- Enh #5223: Query builder now supports selecting sub-queries as columns (qiangxue)
- Enh #5587: `json_encode` is now used with `JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE` where it makes sense, also
it is now default for `Json::encode()` (samdark)
......
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