/**
  * {@inheritdoc}
  */
 public function getEmptyModel()
 {
     if ($this->model === null) {
         $this->model = parent::getEmptyModel();
         $this->model->setId(1);
         if (file_exists($this->fileName)) {
             if ($this->mode == self::MODE_DIFF) {
                 require_once $this->fileName;
             } else {
                 require $this->fileName;
             }
         }
         $values = $this->resolveValues($GLOBALS);
         $this->model->setPropertiesAsArray($values);
     }
     return $this->model;
 }
Ejemplo n.º 2
0
 /**
  * Load property values.
  *
  * @return void
  */
 private function loadPropertyValues()
 {
     $flatten = $this->flatten($this->getData());
     $this->propertyValues = new PropertyValueBag($flatten);
     $this->model->setPropertiesAsArray($flatten);
     foreach ($this->getForms() as $form) {
         foreach ($form->getFields() as $field) {
             $defintion = $this->environment->getDataDefinition()->getPropertiesDefinition();
             $defintion->addProperty($field);
             if (!$this->isSubmit()) {
                 continue;
             }
             $value = $this->environment->getInputProvider()->getValue($field->getName(), true);
             // Set value to property values and to model. If validation failed, the widget manager loads data
             // from the model.
             $this->model->setProperty($field->getName(), $value);
             $this->propertyValues->setPropertyValue($field->getName(), $value);
         }
     }
 }