Пример #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;
 }
Пример #2
0
 /**
  * Gets the defined models in the system
  * @param boolean $includeCustomModels
  * @param boolean $includeModuleModels
  * @param boolean $includeLocalizedModels
  * @param boolean $includeLinkModels
  * @return array Array with Model objects
  */
 private function getModels($includeCustomModels, $includeModuleModels, $includeLocalizedModels, $includeLinkModels)
 {
     if (!$includeCustomModels && !$includeModuleModels && !$includeLocalizedModels && !$includeLinkModels) {
         return array();
     }
     $modelBuilder = new ModelBuilder();
     if (!$includeModuleModels && !$includeLocalizedModels && !$includeLinkModels) {
         return $modelBuilder->getBuilderModels();
     }
     if (!$includeCustomModels && !$includeLocalizedModels && !$includeLinkModels) {
         return $modelBuilder->getModuleModels();
     }
     $models = ModelManager::getInstance()->getModels(true);
     if ($includeCustomModels && $includeModuleModels && $includeLocalizedModels && $includeLinkModels) {
         return $models;
     }
     $builderModels = $modelBuilder->getBuilderModels();
     $moduleModels = $modelBuilder->getModuleModels();
     if (!$includeCustomModels) {
         foreach ($models as $modelName => $model) {
             if (array_key_exists($modelName, $builderModels) && (!$includeModuleModels || !array_key_exists($modelName, $moduleModels))) {
                 unset($models[$modelName]);
             }
         }
     }
     if (!$includeModuleModels) {
         foreach ($models as $modelName => $model) {
             if (array_key_exists($modelName, $moduleModels) && (!$includeCustomModels || !array_key_exists($modelName, $builderModels))) {
                 unset($models[$modelName]);
             }
         }
     }
     if (!$includeLocalizedModels) {
         foreach ($models as $modelName => $model) {
             if (preg_match('/^(.*)' . LocalizedModel::MODEL_SUFFIX . '$/', $modelName)) {
                 unset($models[$modelName]);
             }
         }
     }
     if (!$includeLinkModels) {
         foreach ($models as $modelName => $model) {
             if (!array_key_exists($modelName, $builderModels) && !array_key_exists($modelName, $moduleModels) && !preg_match('/^(.*)' . LocalizedModel::MODEL_SUFFIX . '$/', $modelName)) {
                 unset($models[$modelName]);
             }
         }
     }
     return $models;
 }