Skip to content

Commit ff5b3ec

Browse files
committed
ApiGenerator - dbModel config
1 parent ef1e59a commit ff5b3ec

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/generator/ApiGenerator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace cebe\yii2openapi\generator;
99

10+
use cebe\yii2openapi\lib\items\DbModel;
1011
use yii\db\mysql\Schema as MySqlSchema;
1112
use SamIT\Yii2\MariaDb\Schema as MariaDbSchema;
1213
use yii\db\pgsql\Schema as PgSqlSchema;
@@ -133,6 +134,15 @@ class ApiGenerator extends Generator
133134
*/
134135
public $excludeModels = [];
135136

137+
/**
138+
* @var array Map for custom dbModels
139+
* @example
140+
* 'dbModel' => [
141+
* 'scenarioDefaultDescription' => " Scenario {name}", @see DbModel::$scenarioDefaultDescription
142+
* ]
143+
*/
144+
public $dbModel = [];
145+
136146
/**
137147
* @var array Map for custom controller names not based on model name for exclusive cases
138148
* @example

src/lib/Config.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ class Config extends BaseObject
109109
*/
110110
public $excludeModels = [];
111111

112+
/**
113+
* @var array Map for custom dbModels
114+
* @example
115+
* 'dbModel' => [
116+
* 'scenarioDefaultDescription' => " Scenario {name}", @see DbModel::$scenarioDefaultDescription
117+
* ]
118+
*/
119+
public $dbModel = [];
120+
112121
/**
113122
* @var array Map for custom controller names not based on model name for exclusive cases
114123
* @example

src/lib/generators/ModelsGenerator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public function generate():CodeFiles
5656
}
5757
foreach ($this->models as $model) {
5858
$className = $model->getClassName();
59+
if (!empty($this->config->dbModel['scenarioDefaultDescription'])) {
60+
$model->scenarioDefaultDescription = $this->config->dbModel['scenarioDefaultDescription'];
61+
}
5962
if ($model->isNotDb === false) {
6063
$this->files->add(new CodeFile(
6164
Yii::getAlias("$modelPath/base/$className.php"),

0 commit comments

Comments
 (0)