Removed dep on API
[ninja.git] / src / op5 / ninja_sdk / orm / ORMStructureManifestGenerator.php
blobb32beaf05053e41ac63d27c86cac62b49a1a6d4c
1 <?php
3 class ORMStructureManifestGenerator extends class_generator {
4 private $full_structure = array();
6 public function __construct( $full_structure ) {
7 $this->full_structure = $full_structure;
8 $this->classname = "orm_structure";
9 $this->set_manifest();
12 public function generate($skip_generated_note = false) {
13 parent::generate($skip_generated_note);
15 foreach( $this->full_structure as $table => $struct ) {
16 $tblresult = array();
17 foreach( $struct['structure'] as $field => $type ) {
18 if( is_array( $type ) ) {
19 $tblresult[$field] = array( 'object', $this->lookup_class($type[0]) );
20 } else {
21 $tblresult[$field] = array( $type );
24 $result[$table] = $tblresult;
26 $this->write('$manifest[%s] = %s;', $table, $tblresult);
30 private function lookup_class( $class ) {
31 foreach( $this->full_structure as $table => $struct ) {
32 if( $struct['class'] == $class ) {
33 return $table;
36 return false;