Exemple #1
0
 public function fetchDataTypes($config, $type = '')
 {
     if ($type == '') {
         $hubTypes = HubType::all();
         $typeDescription = array();
         foreach ($hubTypes as $type) {
             require_once PATH_ROOT . DS . $type->file_path;
             $classpath = $type->class_path;
             if (strpos($classpath, 'Tables') === FALSE) {
                 $model = new $classpath();
             } else {
                 $database = App::get('db');
                 $model = new $classpath($database);
             }
             if (is_subclass_of($model, 'Relational')) {
                 // Get local model fields
                 $modelStructure = $type->structure();
                 // Get related model fields
                 $relationships = $model->introspectRelationships();
                 $modelName = $type->get('type');
                 // Add the related and local fields
                 array_push($typeDescription, array('name' => $modelName, 'structure' => $modelStructure));
             }
         }
         // End foreach
     } else {
         $typeDescription = array();
         $type = HubType::all()->where('type', '=', $type)->row();
         require_once PATH_ROOT . DS . $type->file_path;
         $classpath = $type->class_path;
         if (strpos($classpath, 'Tables') === FALSE) {
             $model = new $classpath();
         } else {
             $database = App::get('db');
             $model = new $classpath($database);
         }
         // Get local model fields
         $modelStructure = $type->structure();
         // Get related model fields
         //$relationships = $model->introspectRelationships();
         $modelName = $type->get('type');
         // Add the related and local fields
         array_push($typeDescription, array('name' => $modelName, 'structure' => $modelStructure));
     }
     return $typeDescription;
 }