protected function _writeSchema($field, $values, $path)
{
$db = ConnectionManager::getDataSource('default');
$prefix = $db->config['prefix'];
$tableList = $this->getControlSource($field);
$modelList = array();
foreach ($tableList as $key => $table) {
$model = Inflector::camelize(Inflector::singularize(str_replace($prefix, '', $table)));
$modelList[$key] = $model;
}
$result = true;
foreach ($values as $value) {
if (!$db->writeSchema(array('model' => $modelList[$value], 'path' => $path))) {
$result = false;
} else {
// pathプロパティを削除
$filename = $path . Inflector::tableize($modelList[$value]) . '.php';
$File = new File($filename);
$content = file_get_contents($filename);
$reg = '/(\\r\\n\\r\\n|\\n\\n)[^\\n]+?\\$path[^\\n]+?;/is';
$content = preg_replace($reg, '', $content);
$File->write($content, 'w+');
$File->close();
}
}
return $result;
}