Esempio n. 1
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);
     }
 }
Esempio 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);
 }