diff --git a/src/Command/BakeCommand.php b/src/Command/BakeCommand.php index 930ac6b9..c55f2f5a 100644 --- a/src/Command/BakeCommand.php +++ b/src/Command/BakeCommand.php @@ -27,6 +27,7 @@ use Cake\Core\ConventionsTrait; use Cake\Event\Event; use Cake\Event\EventManager; +use Cake\ORM\Locator\TableLocator; use InvalidArgumentException; use function Cake\Core\pluginSplit; @@ -48,6 +49,22 @@ abstract class BakeCommand extends Command */ protected string $pathFragment; + /** + * Initialize the command. + * + * @return void + */ + public function initialize(): void + { + parent::initialize(); + + $locator = $this->getTableLocator(); + if ($locator instanceof TableLocator) { + $locator->allowFallbackClass(true); + $this->setTableLocator($locator); + } + } + /** * Get the command name. * diff --git a/src/Command/TemplateCommand.php b/src/Command/TemplateCommand.php index 558187ab..b5868a0a 100644 --- a/src/Command/TemplateCommand.php +++ b/src/Command/TemplateCommand.php @@ -100,6 +100,8 @@ class TemplateCommand extends BakeCommand */ public function initialize(): void { + parent::initialize(); + $this->path = current(App::path('templates')); }