Exemplo n.º 1
0
 /**
  * Processes the finish action of this step. This will write the model to the system
  * @return null
  */
 public function finish()
 {
     $defineModel = $this->wizard->getValue(self::FIELD_DEFINE_MODEL);
     $modelTable = $this->wizard->getModelTable();
     $modelClass = $this->wizard->getVariable(BuilderWizard::VARIABLE_MODEL_CLASS);
     $dataClass = $this->wizard->getVariable(BuilderWizard::VARIABLE_DATA_CLASS);
     try {
         $modelBuilder = new ModelBuilder();
         $model = $modelBuilder->createModel($modelTable, $modelClass, $dataClass);
         $modelBuilder->registerModel($model, $defineModel);
         $request = $this->wizard->getRequest();
         $response = $this->wizard->getResponse();
         $this->wizard->reset();
         $response->setRedirect($this->wizard->getCancelUrl());
     } catch (Exception $exception) {
         Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString());
         $this->exception = $exception;
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * Action to order the fields of a model
  * @param string $modelName Name of the model
  * @return null
  */
 public function orderFieldsAction($modelName)
 {
     $basePath = $this->request->getBasePath();
     $orderForm = new ModelFieldOrderForm($basePath . '/' . self::ACTION_ORDER_FIELDS . '/' . $modelName);
     if (!$orderForm->isSubmitted()) {
         $this->request->setRedirect($basePath);
         return;
     }
     $model = ModelManager::getInstance()->getModel($modelName);
     $modelTable = $model->getMeta()->getModelTable();
     $fieldOrder = $orderForm->getOrder();
     try {
         $modelTable->orderFields($fieldOrder);
         $modelBuilder = new ModelBuilder();
         $modelBuilder->registerModel($model);
         $this->addInformation(self::TRANSLATION_ORDER_FIELDS_SUCCESS);
     } catch (Exception $exception) {
         Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString());
         $this->addError(self::TRANSLATION_ORDER_FIELDS_ERROR, array('error' => $exception->getMessage()));
     }
     $this->response->setRedirect($basePath . '/' . self::ACTION_DETAIL . '/' . $modelName);
 }