Skip to content

Commit

Permalink
ModelClassDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
siggi-k committed Aug 22, 2024
1 parent 444bfae commit f546b4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/generator/default/dbmodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
<?= '<?php' ?>


/**
* This file is generated by Gii, do not change manually!
*/

namespace <?= $namespace ?>;

/**
*<?= empty($model->description) ? '' : str_replace("\n", "\n * ", ' ' . trim($model->description)) ?>
*<?= $model->getModelClassDescription() ?>

*
<?php foreach ($model->dbAttributes() as $attribute): ?>
Expand Down Expand Up @@ -48,7 +52,7 @@ abstract class <?= $model->getClassName() ?> extends \yii\db\ActiveRecord
<?php if($scenarios = $model->getScenarios()):
foreach($scenarios as $scenario): ?>
/**
* <?=$scenario['description']?>
* <?= $scenario['description'] ?>

*/
public const <?= $scenario['const'] ?> = '<?= $scenario['name'] ?>';
Expand Down
6 changes: 6 additions & 0 deletions src/lib/items/DbModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,10 @@ private function getScenariosByOpenapiSchema(): array
return $scenarios;
}

public function getModelClassDescription()
{
return !empty($this->description) ?
str_replace("\n", "\n *", ' ' . trim($this->description))
: ' This is the model class for table "'.$this->tableName.'".';
}
}

0 comments on commit f546b4c

Please sign in to comment.