/** * @return void */ public function update() { parent::update(); $this->getResource()->update(); }
/** * @return void */ protected function update() { parent::update(); $this->getDao()->update(); }
/** * @throws \Exception */ protected function update() { $fieldDefintions = $this->getClass()->getFieldDefinitions(); foreach ($fieldDefintions as $fd) { $getter = "get" . ucfirst($fd->getName()); $setter = "set" . ucfirst($fd->getName()); if (method_exists($this, $getter)) { //To make sure, inherited values are not set again $inheritedValues = AbstractObject::doGetInheritedValues(); AbstractObject::setGetInheritedValues(false); $value = $this->{$getter}(); if (is_array($value) and ($fd instanceof ClassDefinition\Data\Multihref or $fd instanceof ClassDefinition\Data\Objects)) { //don't save relations twice $this->{$setter}(array_unique($value)); } AbstractObject::setGetInheritedValues($inheritedValues); $value = $this->{$getter}(); $omitMandatoryCheck = $this->getOmitMandatoryCheck(); /*$timeSinceCreation = (time()-$this->getCreationDate()); if($timeSinceCreation <= 5){ // legacy hack: in previous version there was no check for mandatory fields, // and everybody uses the save method for new object creation - so now let's evict the mandatory check // if the object was created within the last 5 seconds $omitMandatoryCheck=true; \Logger::debug("executing mandatory fields check for object [ ".$this->getId()." ]"); } */ //check throws Exception try { $fd->checkValidity($value, $omitMandatoryCheck); } catch (\Exception $e) { if ($this->getClass()->getAllowInherit()) { //try again with parent data when inheritance in activated try { $getInheritedValues = AbstractObject::doGetInheritedValues(); AbstractObject::setGetInheritedValues(true); $value = $this->{$getter}(); $fd->checkValidity($value, $omitMandatoryCheck); AbstractObject::setGetInheritedValues($getInheritedValues); } catch (\Exception $e) { throw new \Exception($e->getMessage() . " fieldname=" . $fd->getName()); } } else { throw new \Exception($e->getMessage() . " fieldname=" . $fd->getName()); } } } } parent::update(); $this->getResource()->update(); // scheduled tasks are saved in $this->saveVersion(); $this->saveVersion(false, false); $this->saveChilds(); }
/** * @throws \Exception */ protected function update() { $fieldDefintions = $this->getClass()->getFieldDefinitions(); foreach ($fieldDefintions as $fd) { $getter = "get" . ucfirst($fd->getName()); $setter = "set" . ucfirst($fd->getName()); if (method_exists($this, $getter)) { //To make sure, inherited values are not set again $inheritedValues = AbstractObject::doGetInheritedValues(); AbstractObject::setGetInheritedValues(false); $value = $this->{$getter}(); if (is_array($value) and ($fd instanceof ClassDefinition\Data\Multihref or $fd instanceof ClassDefinition\Data\Objects)) { //don't save relations twice $this->{$setter}(array_unique($value)); } AbstractObject::setGetInheritedValues($inheritedValues); $value = $this->{$getter}(); $omitMandatoryCheck = $this->getOmitMandatoryCheck(); //check throws Exception try { $fd->checkValidity($value, $omitMandatoryCheck); } catch (\Exception $e) { if ($this->getClass()->getAllowInherit()) { //try again with parent data when inheritance in activated try { $getInheritedValues = AbstractObject::doGetInheritedValues(); AbstractObject::setGetInheritedValues(true); $value = $this->{$getter}(); $fd->checkValidity($value, $omitMandatoryCheck); AbstractObject::setGetInheritedValues($getInheritedValues); } catch (\Exception $e) { throw new \Exception($e->getMessage() . " fieldname=" . $fd->getName()); } } else { throw new \Exception($e->getMessage() . " fieldname=" . $fd->getName()); } } } } parent::update(); $this->getDao()->update(); // scheduled tasks are saved in $this->saveVersion(); $this->saveVersion(false, false); $this->saveChildData(); }
/** * @return void */ public function update() { parent::update(); $this->getDao()->update(); }