mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Enh #6857: Added yii\gii\Module::$ignoreTables that allows you to ignore tables during model generation using *
This commit is contained in:
committed by
Alexander Makarov
parent
06564db627
commit
e562f8e43a
@ -4,7 +4,7 @@ Yii Framework 2 gii extension Change Log
|
||||
2.0.3 under development
|
||||
-----------------------
|
||||
|
||||
- no changes in this release.
|
||||
- Enh #6857: Added `yii\gii\Module::$ignoreTables` that allows you to ignore tables during model generation using `*` (thiagotalma)
|
||||
|
||||
|
||||
2.0.2 January 11, 2015
|
||||
|
||||
@ -77,6 +77,11 @@ class Module extends \yii\base\Module implements BootstrapInterface
|
||||
* Defaults to 0777, meaning the directory can be read, written and executed by all users.
|
||||
*/
|
||||
public $newDirMode = 0777;
|
||||
/**
|
||||
* @var array the list of table names to be ignored.
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public $ignoreTables = [];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -525,6 +525,7 @@ class Generator extends \yii\gii\Generator
|
||||
}
|
||||
$tableNames = [];
|
||||
if (strpos($this->tableName, '*') !== false) {
|
||||
$module = Yii::$app->controller->module;
|
||||
if (($pos = strrpos($this->tableName, '.')) !== false) {
|
||||
$schema = substr($this->tableName, 0, $pos);
|
||||
$pattern = '/^' . str_replace('*', '\w+', substr($this->tableName, $pos + 1)) . '$/';
|
||||
@ -534,6 +535,10 @@ class Generator extends \yii\gii\Generator
|
||||
}
|
||||
|
||||
foreach ($db->schema->getTableNames($schema) as $table) {
|
||||
if (in_array($table, $module->ignoreTables)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match($pattern, $table)) {
|
||||
$tableNames[] = $schema === '' ? $table : ($schema . '.' . $table);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user