public function bakeTable($model, array $data = [])
{
if (!empty($this->params['no-table'])) {
return null;
}
$namespace = Configure::read('App.namespace');
$pluginPath = '';
if ($this->plugin) {
$namespace = $this->_pluginNamespace($this->plugin);
}
$name = $model->alias();
$entity = $this->_entityName($model->alias());
$data += ['plugin' => $this->plugin, 'pluginPath' => $pluginPath, 'namespace' => $namespace, 'name' => $name, 'entity' => $entity, 'associations' => [], 'primaryKey' => 'id', 'displayField' => null, 'table' => null, 'validation' => [], 'rulesChecker' => [], 'behaviors' => [], 'connection' => $this->connection];
$this->BakeTemplate->set($data);
$out = $this->BakeTemplate->generate('Model/table');
$path = $this->getPath();
$filename = $path . 'Table' . DS . $name . 'Table.php';
$this->out("\n" . sprintf('Baking table class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out);
// Work around composer caching that classes/files do not exist.
// Check for the file as it might not exist in tests.
if (file_exists($filename)) {
require_once $filename;
}
TableRegistry::clear();
$emptyFile = $path . 'Table' . DS . 'empty';
$this->_deleteEmptyFile($emptyFile);
return $out;
}