/** * Write model body code. * * @param \MwbExporter\Writer\WriterInterface $writer * @return \MwbExporter\Formatter\Node\Sequelize\Model\Table */ protected function writeBody(WriterInterface $writer) { $writer->writeCallback(function (WriterInterface $writer, Table $_this = null) { if ($_this->getConfig()->get(Formatter::CFG_ADD_COMMENT)) { $writer->write($_this->getFormatter()->getComment(Comment::FORMAT_JS))->write(''); } })->write("module.exports = function(sequelize, DataTypes) {")->indent()->write("return sequelize.define('%s', %s, %s);", $this->getModelName(), $this->asModel(), $this->asOptions())->outdent()->write("}"); return $this; }
/** * Write model body code. * * @param \MwbExporter\Writer\WriterInterface $writer * @return \MwbExporter\Formatter\Sencha\ExtJS4\Model\Table */ public function writeBody(WriterInterface $writer) { $writer->writeCallback(function (WriterInterface $writer, Table $_this = null) { if ($_this->getConfig()->get(Formatter::CFG_ADD_COMMENT)) { $writer->write($_this->getFormatter()->getComment(Comment::FORMAT_JS))->write(''); } })->write("Ext.define('%s', %s);", $this->getClassPrefix() . '.' . $this->getModelName(), $this->asModel()); return $this; }
public function writeRelationships(WriterInterface $writer) { $writer->writeCallback(function (WriterInterface $writer, Table $_this = null) { if (count($_this->getForeignKeys())) { foreach ($_this->getForeignKeys() as $foreignKey) { $foreignKey->write($writer); } } }); return $this; }