Skip to content

Commit 9a639c0

Browse files
authored
Merge pull request #1047 from cakephp/3.5-tablelocator-fallback
Ensure fallback class is enabled for the table locator.
2 parents 2c47908 + 730f6c3 commit 9a639c0

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/Command/BakeCommand.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Cake\Core\ConventionsTrait;
2828
use Cake\Event\Event;
2929
use Cake\Event\EventManager;
30+
use Cake\ORM\Locator\TableLocator;
3031
use InvalidArgumentException;
3132
use function Cake\Core\pluginSplit;
3233

@@ -48,6 +49,22 @@ abstract class BakeCommand extends Command
4849
*/
4950
protected string $pathFragment;
5051

52+
/**
53+
* Initialize the command.
54+
*
55+
* @return void
56+
*/
57+
public function initialize(): void
58+
{
59+
parent::initialize();
60+
61+
$locator = $this->getTableLocator();
62+
if ($locator instanceof TableLocator) {
63+
$locator->allowFallbackClass(true);
64+
$this->setTableLocator($locator);
65+
}
66+
}
67+
5168
/**
5269
* Get the command name.
5370
*

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

0 commit comments

Comments
 (0)