Exemplo n.º 1
0
 public function decorateRepresentation(\Extool\Representation\Representation &$rep)
 {
     $this->parse();
     if (isset($this->parsed['project'])) {
         $rep->setName($this->parsed['project']);
     } else {
         throw new Exception("Plan is not in NapkinSketch format.");
     }
     $tables = $this->getTables();
     foreach ($tables as $table) {
         $rep->addTable($table);
     }
     foreach ($this->views as $view) {
         $rep->addPublicView($view);
     }
     foreach ($this->adminViews as $view) {
         $rep->addAdminView($view);
     }
     foreach ($this->models as $model) {
         $rep->addPublicModel($model);
     }
     foreach ($this->adminModels as $model) {
         $rep->addAdminModel($model);
     }
     // TODO: models, views
 }
Exemplo n.º 2
0
 public function decorateRepresentation(\Extool\Representation\Representation &$rep)
 {
     $this->parse();
     $pieces = explode('/', $this->resource);
     $resource_name = ucfirst(preg_replace('/\\..*/', '', array_pop($pieces)));
     $rep->setName($resource_name);
     $fields = $this->determineFields();
     $data = new \Extool\Representation\Data($fields);
     $data->setData($this->keyed_data);
     $rep->addData($data, $resource_name);
     $table = new \Extool\Representation\Table($resource_name);
     $table->setFields($fields);
     $rep->addTable($table);
     $model = new \Extool\Representation\Model($resource_name);
     $model->setCriteria($fields);
     $model->addTable($table);
     $view = new \Extool\Representation\View($resource_name);
     $view->setFields($fields);
     $rep->addPublicView($view);
     $rep->addPublicModel($model);
     $view->setAccess('admin');
     $rep->addAdminView($view);
     $rep->addAdminModel($model);
     // Create new model for the list views
     $model = new \Extool\Representation\Model($resource_name . ' List');
     $model->setCriteria($fields);
     $model->addTable($table);
     $view = new \Extool\Representation\View($resource_name . ' List');
     $view->setType('list');
     $view->setFields($fields);
     $rep->addPublicView($view);
     $rep->addPublicModel($model);
     $view->setAccess('admin');
     $rep->addAdminView($view);
     $rep->addAdminModel($model);
 }
Exemplo n.º 3
0
 public function decorateRepresentation(\Extool\Representation\Representation &$rep)
 {
     $this->parse();
     $pieces = explode('/', $this->resource);
     $rep->setName(ucfirst(array_pop($pieces)));
     foreach ($this->table_fields as $table_name => $fields) {
         $table = new \Extool\Representation\Table($table_name);
         $table->setFields($fields);
         $rep->addTable($table);
         $model = new \Extool\Representation\Model($table_name);
         $model->setCriteria($fields);
         $model->addTable($table);
         // Generate four views for each table
         $view = new \Extool\Representation\View($table_name);
         $view->setFields($fields);
         $rep->addPublicView($view);
         $rep->addPublicModel($model);
         $view->setAccess('admin');
         $rep->addAdminView($view);
         $rep->addAdminModel($model);
         // Create new model for the list views
         $model = new \Extool\Representation\Model($table_name . ' List');
         $model->setCriteria($fields);
         $model->addTable($table);
         $view = new \Extool\Representation\View($table_name . ' List');
         $view->setType('list');
         $view->setFields($fields);
         $rep->addPublicView($view);
         $rep->addPublicModel($model);
         $view->setAccess('admin');
         $rep->addAdminView($view);
         $rep->addAdminModel($model);
     }
 }