Пример #1
0
 public function convert(Schema $schema)
 {
     $result = array('models' => array());
     foreach ($schema->getModels() as $model) {
         $result['models'][$model->getName()] = $this->modelAsArray($model);
     }
     return $result;
 }
Пример #2
0
 public function convert(\Cti\Storage\Schema $inputSchema)
 {
     $schema = new \Doctrine\DBAL\Schema\Schema();
     foreach ($inputSchema->getModels() as $model) {
         $table = $schema->createTable($model->getName());
         foreach ($model->getProperties() as $property) {
             $params = array('comment' => $property->getComment(), 'notnull' => $property->getRequired());
             $type = $property->getType();
             if ($type === 'char') {
                 $type = 'string';
                 $params['length'] = 1;
             }
             $table->addColumn($property->getName(), $type, $params);
         }
         $table->setPrimaryKey($model->getPk());
         foreach ($model->getIndexes() as $index) {
             $table->addIndex($index->getFields());
         }
     }
     foreach ($inputSchema->getModels() as $model) {
         $table = $schema->getTable($model->getName());
         foreach ($model->getOutReferences() as $reference) {
             if ($inputSchema->getModel($reference->getDestination())->getBehaviour("log")) {
                 continue;
             }
             $destination = $schema->getTable($reference->getDestination());
             $foreignProperties = array();
             foreach ($reference->getProperties() as $property) {
                 $foreignProperties[] = $property->getForeignName();
             }
             $localProperties = array_keys($reference->getProperties());
             $table->addForeignKeyConstraint($destination, $localProperties, $foreignProperties);
         }
     }
     foreach ($inputSchema->getSequences() as $sequence) {
         $schema->createSequence($sequence->getName());
     }
     return $schema;
 }
Пример #3
0
    function getGeneratedCode()
    {
        $list = array();
        foreach ($this->schema->getModels() as $model) {
            if (!$model->hasBehaviour('link')) {
                $list[] = "splashClass: 'Grid." . $model->getClassName() . "'";
            }
        }
        $list = implode(PHP_EOL . '    ,' . PHP_EOL . '      ', $list);
        return <<<COFFEE
Ext.define 'Generated.Master'

  extend: 'Cti.Splash'
  title: 'Доступные модели'

  token: '/_master'
  
  initComponent: ->
    @list = [
      {$list}
    ]
    @callParent arguments        
COFFEE;
    }