Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Oct 25, 2023
2 parents 29b8a9b + b56c85c commit 52c2222
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-scss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3.0.0
uses: actions/setup-node@v4.0.0
with:
# node version based on dart-sass test workflow
node-version: 16
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"phpunit/phpcov": "^8.2",
"phpunit/phpunit": "^9.1",
"predis/predis": "^1.1 || ^2.0",
"rector/rector": "0.18.5",
"rector/rector": "0.18.6",
"vimeo/psalm": "^5.0"
},
"suggest": {
Expand Down
7 changes: 3 additions & 4 deletions system/Commands/Generators/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ protected function prepare(string $class): string
$baseClass = $match[1];
}

$table = is_string($table) ? $table : plural(strtolower($baseClass));
$dbGroup = is_string($dbGroup) ? $dbGroup : 'default';
$return = is_string($return) ? $return : 'array';
$table = is_string($table) ? $table : plural(strtolower($baseClass));
$return = is_string($return) ? $return : 'array';

if (! in_array($return, ['array', 'object', 'entity'], true)) {
// @codeCoverageIgnoreStart
Expand All @@ -129,6 +128,6 @@ protected function prepare(string $class): string
$return = "'{$return}'";
}

return $this->parseTemplate($class, ['{table}', '{dbGroup}', '{return}'], [$table, $dbGroup, $return]);
return $this->parseTemplate($class, ['{dbGroup}', '{table}', '{return}'], [$dbGroup, $table, $return], compact('dbGroup'));
}
}
2 changes: 2 additions & 0 deletions system/Commands/Generators/Views/model.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

class {class} extends Model
{
<?php if (is_string($dbGroup)): ?>
protected $DBGroup = '{dbGroup}';
<?php endif; ?>
protected $table = '{table}';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
Expand Down
1 change: 0 additions & 1 deletion tests/system/Commands/ModelGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function testGenerateModel(): void
$this->assertFileExists($file);
$this->assertStringContainsString('extends Model', $this->getFileContent($file));
$this->assertStringContainsString('protected $table = \'users\';', $this->getFileContent($file));
$this->assertStringContainsString('protected $DBGroup = \'default\';', $this->getFileContent($file));
$this->assertStringContainsString('protected $returnType = \'array\';', $this->getFileContent($file));
}

Expand Down

0 comments on commit 52c2222

Please sign in to comment.