protected function setRoot(InterfaceGeneralModel $objCurrentEntry, $strTable)
 {
     $arrRootSetter = $this->getDC()->getRootSetter($strTable);
     if (!($arrRootSetter && $arrRootSetter)) {
         throw new Exception("Can not calculate parent.", 1);
     }
     foreach ($arrRootSetter as $arrCondition) {
         if ($arrCondition['property'] && isset($arrCondition['value'])) {
             $objCurrentEntry->setProperty($arrCondition['property'], $arrCondition['value']);
         } else {
             throw new Exception("Error Processing root condition, you need to specify property and value: " . var_export($arrCondition, true), 1);
         }
     }
 }
Example #2
0
 /**
  * Update the current model from a post request. Additionally, trigger meta palettes, if installed.
  */
 public function updateModelFromPOST()
 {
     // callback to tell visitors that we have just updated the model.
     $this->getCallbackClass()->onModelBeforeUpdateCallback($this->getCurrentModel());
     // process input and update changed properties.
     foreach (array_keys($this->getFieldList()) as $strKey) {
         $varNewValue = $this->processInput($strKey);
         if ($varNewValue !== NULL && $this->objCurrentModel->getProperty($strKey) !== $varNewValue) {
             $this->objCurrentModel->setProperty($strKey, $varNewValue);
             $this->objCurrentModel->setMeta(DCGE::MODEL_IS_CHANGED, true);
         }
     }
     if (in_array($this->arrDCA['list']['sorting']['mode'], array(4, 5, 6)) && strlen(Input::getInstance()->get('pid')) > 0) {
         // pull correct condition from DCA and update according to setOn values.
         $objParentModel = $this->getDataProvider('parent')->fetch($this->getDataProvider('parent')->getEmptyConfig()->setId(Input::getInstance()->get('pid')));
         $arrCond = $this->getParentChildCondition($objParentModel, $this->getDataProvider()->getEmptyModel()->getProviderName());
         if (is_array($arrCond) && key_exists('setOn', $arrCond)) {
             foreach ($arrCond['setOn'] as $arrSetOn) {
                 if ($arrSetOn['from_field']) {
                     $this->objCurrentModel->setProperty($arrSetOn['to_field'], $objParentModel->getProperty($arrSetOn['from_field']));
                 } else {
                     $this->objCurrentModel->setProperty($arrSetOn['to_field'], $arrSetOn['value']);
                 }
             }
         }
     }
     // TODO: is this really a wise idea here?
     if (in_array('metapalettes', Config::getInstance()->getActiveModules())) {
         MetaPalettes::getInstance()->generateSubSelectPalettes($this);
     }
     // callback to tell visitors that we have just updated the model.
     $this->getCallbackClass()->onModelUpdateCallback($this->getCurrentModel());
 }