Skip to content

Commit 0226b5d

Browse files
committed
Ensure fallback class is enabled for the table locator.
It's recommended to disable fallback class during normal functioning of the app but fallback needs to be enabled when baking as the required table classes might still not have been created.
1 parent 2c47908 commit 0226b5d

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/Command/BakeCommand.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ abstract class BakeCommand extends Command
4848
*/
4949
protected string $pathFragment;
5050

51+
/**
52+
* Initialize the command.
53+
*
54+
* @return void
55+
*/
56+
public function initialize(): void
57+
{
58+
parent::initialize();
59+
60+
/** @phpstan-ignore method.notFound */
61+
$this->getTableLocator()->allowFallbackClass(true);
62+
}
63+
5164
/**
5265
* Get the command name.
5366
*

src/Command/TemplateCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class TemplateCommand extends BakeCommand
100100
*/
101101
public function initialize(): void
102102
{
103+
parent::initialize();
104+
103105
$this->path = current(App::path('templates'));
104106
}
105107

tests/TestCase/Command/ModelCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ public function testGetValidationTree()
12811281
],
12821282
'depth' => [
12831283
'nonNegativeInteger' => ['rule' => 'nonNegativeInteger', 'args' => []],
1284-
'allowEmpty' => ['rule' => 'allowEmptyString', 'args' => []],
1284+
'allowEmpty' => ['rule' => 'allowEmpty', 'args' => []],
12851285
],
12861286
];
12871287
$this->assertEquals($expected, $result);

0 commit comments

Comments
 (0)