Esempio n. 1
0
 private function parseViews($prefix = '')
 {
     $views = array();
     preg_match_all('/^' . $prefix . 'view\\s+(.+)\\s*\\((.+)\\)/sUm', $this->raw_plan, $matches);
     foreach ($matches[1] as $i => $view_name) {
         preg_match_all('/(\\w+):\\s+(.+)/', $matches[2][$i], $fields);
         $tables = $this->getMatchedProperties($fields, true);
         $model = $this->makeModel($tables, $view_name, $prefix);
         $merged_fields = new \Extool\Representation\Fields();
         foreach ($model->tables as $table) {
             foreach ($table->fields as $field_name => $type) {
                 $merged_fields->addField($field_name, $type);
             }
         }
         $view = new \Extool\Representation\View($view_name);
         if ($prefix == 'admin') {
             $view->setAccess('admin');
         }
         if (preg_match('/ list$/i', $view_name)) {
             $view->setType('list');
         }
         $view->setFields($merged_fields);
         $views[$view_name] = $view;
     }
     return $views;
 }