Skip to content

Instantly share code, notes, and snippets.

@inoas
Created September 12, 2019 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inoas/78f24f3024a449af3e2675ae61d439b7 to your computer and use it in GitHub Desktop.
Save inoas/78f24f3024a449af3e2675ae61d439b7 to your computer and use it in GitHub Desktop.
<?php
/*
* Disable generic table classes unless cake bake is running
*/
if ((PHP_SAPI === 'cli' && array_key_exists(1, env('argv')) && env('argv')[1] === 'bake') === false) {
// TODO entity initialize => similar error
EventManager::instance()->on('Model.initialize', function($event) {
if (get_class($event->getSubject()) === Table::class) {
$msg = sprintf(
'Missing or miss-referenced table class for database table %s (auto-tables).',
$event->getSubject()->getTable()
);
if (Configure::read('debug') === false) {
Log::warning($msg);
} else {
throw new InternalErrorException($msg);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment