Skip to content

Commit ef1e59a

Browse files
committed
custom scenarioDefaultDescription
1 parent 5c7fa9b commit ef1e59a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/lib/items/DbModel.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class DbModel extends BaseObject
8787
*/
8888
private array $scenarios;
8989

90+
/**
91+
* @var string
92+
* Here, you can set your own default description for the scenario.
93+
* You can use the {name} attribute from the schema for the YAML model.
94+
*/
95+
public string $scenarioDefaultDescription = " Scenario {name}";
96+
9097
public function getTableAlias():string
9198
{
9299
return '{{%' . $this->tableName . '}}';
@@ -227,9 +234,12 @@ private function getScenariosByOpenapiSchema(): array
227234

228235
foreach ($scenarios as $key => $scenario) {
229236
$scenarios[$key]['const'] = 'SCENARIO_' . strtoupper($scenario['name']);
230-
$scenarios[$key]['description'] = !empty($scenario['description']) ?
231-
FormatHelper::getFormattedDescription($scenario['description'], 5)
232-
: ' Scenario ' . $scenario['name'];
237+
$scenarios[$key]['description'] = FormatHelper::getFormattedDescription(
238+
!empty($scenario['description']) ?
239+
$scenario['description']
240+
: str_replace('{name}', $scenario['name'], $this->scenarioDefaultDescription
241+
),
242+
5);
233243
}
234244

235245
return $scenarios;

0 commit comments

Comments
 (0)