本文整理汇总了PHP中Object_Abstract::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Object_Abstract::update方法的具体用法?PHP Object_Abstract::update怎么用?PHP Object_Abstract::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object_Abstract
的用法示例。
在下文中一共展示了Object_Abstract::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* @return void
*/
protected function update()
{
$fieldDefintions = $this->getO_class()->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 = Object_Abstract::doGetInheritedValues();
Object_Abstract::setGetInheritedValues(false);
$value = $this->{$getter}();
if (is_array($value) and ($fd instanceof Object_Class_Data_Multihref or $fd instanceof Object_Class_Data_Objects)) {
//don't save relations twice
$this->{$setter}(array_unique($value));
}
Object_Abstract::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->getO_class()->getAllowInherit()) {
//try again with parent data when inheritance in activated
try {
$getInheritedValues = Object_Abstract::doGetInheritedValues();
Object_Abstract::setGetInheritedValues(true);
$value = $this->{$getter}();
$fd->checkValidity($value, $omitMandatoryCheck);
Object_Abstract::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();
$this->saveScheduledTasks();
$this->saveVersion(false, false);
$this->saveChilds();
Pimcore_API_Plugin_Broker::getInstance()->postUpdateObject($this);
}
示例2: update
/**
* @return void
*/
public function update()
{
parent::update();
$this->getResource()->update();
Pimcore_API_Plugin_Broker::getInstance()->postUpdateObject($this);
}