/**
  * Get the node settings from this form
  * @param boolean $updateValues set to true to get the submitted node settings, false to get the initial node settings
  * @return joppa\model\NodeSettings
  * @throws zibo\ZiboException when the form is not submitted and $updateValues is set to true
  * @throws zibo\library\validation\exception\ValidationException when the submitted settings are not valid and $updateValues is set to true
  */
 public function getNodeSettings($updateValues = true)
 {
     if (!$updateValues) {
         return $this->nodeSettings;
     }
     if (!$this->isSubmitted()) {
         throw new ZiboException('Form not submitted');
     }
     $settings = @parse_ini_string($this->getValue(self::FIELD_SETTINGS));
     if ($settings === false) {
         $error = error_get_last();
         $error = new ValidationError('error', '%error%', array('error' => $error['message']));
         $exception = new ValidationException();
         $exception->addErrors(self::FIELD_SETTINGS, array($error));
         throw $exception;
     }
     $nodeSettings = new NodeSettings($this->nodeSettings->getNode(), $this->nodeSettings->getInheritedNodeSettings());
     // set the values from the form
     $inheritPrefixLength = strlen(NodeSettings::INHERIT_PREFIX);
     foreach ($settings as $key => $value) {
         $inherit = false;
         if (strlen($key) > $inheritPrefixLength && strncmp($key, NodeSettings::INHERIT_PREFIX, $inheritPrefixLength) == 0) {
             $key = substr($key, $inheritPrefixLength);
             $inherit = true;
         }
         $nodeSettings->set($key, $value, $inherit);
     }
     return $nodeSettings;
 }
 /**
  * Save a NodeSettings object to the model
  * @param NodeSettings $nodeSettings
  * @param boolean $setInheritToAll set to true if all settings should be inherit to lower levels
  * @return null
  * @throws zibo\library\validation\exception\ValidationException when not all settings are valid
  * @throws Exception when the save fails
  */
 public function setNodeSettings(NodeSettings $nodeSettings, $setInheritToAll = false)
 {
     $nodeModel = $this->getModel(NodeModel::NAME);
     $node = $nodeSettings->getNode();
     $validator = new NodeSettingsValidator();
     $validator->validateNodeSettings($nodeSettings);
     $settings = $nodeSettings->getArray();
     foreach ($settings as $key => $nodeSetting) {
         if (String::isEmpty($nodeSetting->value)) {
             unset($settings[$key]);
             continue;
         }
         $nodeSetting->id = 0;
         $nodeSetting->node = $node->id;
         if ($setInheritToAll) {
             $nodeSetting->inherit = true;
         }
     }
     $transactionStarted = $this->startTransaction();
     try {
         $this->delete($this->findByNodeId($node->id));
         $this->save($settings);
         $this->commitTransaction($transactionStarted);
     } catch (Exception $e) {
         $this->rollbackTransaction($transactionStarted);
         throw $e;
     }
 }