----------
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
----------
/** * Get array replacements. * * @return array */ public function getReplacements() { $modelGenerator = new ModelGenerator(['name' => $this->name]); $model = $modelGenerator->getRootNamespace() . '\\' . $modelGenerator->getName(); $model = str_replace(["\\", '/'], '\\', $model); return array_merge(parent::getReplacements(), ['model' => $model]); }
public function actionNewModel() { $this->templates['model.php'] = Yii::getPathOfAlias('application.components.codegen.templates'); $model = new DevGenNewModel(); $href = ""; if (isset($_POST['DevGenNewModel']) && $_POST['DevGenNewModel']['tableName'] != "" && $_POST['DevGenNewModel']['modelName'] != "") { $s = $_POST['DevGenNewModel']; $tableName = $s['tableName']; $modelName = $s['modelName']; $module = $s['module'] == 'plansys' ? 'application' : 'app'; $options = []; if ($s['softDelete'] == 'Yes') { $options['softDelete'] = ['column' => $s['softDeleteColumn'], 'value' => $s['softDeleteValue']]; } ModelGenerator::create($tableName, $modelName, $module, $options); $href = Yii::app()->createUrl('/dev/genModel/index', ['active' => $s['module'] . "." . $modelName]); } $this->renderForm("DevGenNewModel", $model, ['href' => $href], ['layout' => '//layouts/blank']); }
<div ui-layout class="sub" options="{ flow : 'column' }"> <div ui-layout-container > <div ui-header> <?php echo $modelDetail['modelClass']; ?> <br> </div> <div ui-content> <table class="table table-responsive" style="background:#f6f6f6;"> <tr> <td><b>Source Code</b></td> </tr> <tr> <td><span class="code"><?php echo ModelGenerator::getModelPath($class, $type); ?> </span></td> </tr> <tr> <td><b>Table Name<b></td> </tr> <tr> <td><?php echo $modelDetail['tableName']; ?> </td> </tr> </table> <div ui-header> Attributes<br>
/** * Get array replacements. * * @return array */ public function getReplacements() { $modelGenerator = new ModelGenerator(); return array_merge(parent::getReplacements(), ['model_namespace' => $modelGenerator->getRootNamespace()]); }
<?php ## AUTOGENERATED OPTIONS - DO NOT EDIT $options = array('mode' => 'custom', 'layout' => array('size' => '200', 'sizetype' => 'px', 'type' => 'menu', 'name' => 'col1', 'file' => 'application.modules.dev.menus.GenModel', 'inlineJS' => 'GenModel.js')); ## END OF AUTOGENERATED OPTIONS return ModelGenerator::listMenuTree();
<?php require_once "lib/lworm/ModelGenerator.class.php"; $mg = new ModelGenerator(); $mg->generateModel('test.yaml', 'model'); require_once "lib/lworm/gae/GAEDataStoreFactory.class.php"; require_once "model/User.class.php"; require_once "model/Group.class.php"; require_once "model/Role.class.php"; $ds = GAEDataStoreFactory::getDataStore(); // insert $user = new User(); $user->setName("test"); $ds->save($user); // update $user->setPassword("test"); $ds->save($user); //var_dump($user); // read $user2 = $ds->getEntity(User, $user->getId()); //var_dump($user2); // many to one $group = new Group(); $group->setName("test"); $ds->save($group); $user->getGroupRelation($ds)->setEntity($group); $user = new User(); $user->setName("test 2"); $ds->save($user); $user->getGroupRelation($ds)->setEntity($group); //var_dump($user->getGroupRelation($ds)->getEntity($group));