本文整理匯總了PHP中Magento\Framework\Model\AbstractModel::hasDataChanges方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractModel::hasDataChanges方法的具體用法?PHP AbstractModel::hasDataChanges怎麽用?PHP AbstractModel::hasDataChanges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::hasDataChanges方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save
/**
* {@inheritdoc}
*/
public function save(\Magento\Framework\Model\AbstractModel $object)
{
$hasDataChanges = $object->hasDataChanges();
$object->setIsOptionsSaved(false);
$result = parent::save($object);
if ($hasDataChanges && !$object->isOptionsSaved()) {
$object->saveItemOptions();
}
return $result;
}
示例2: isValid
/**
* Successful if $value is \Magento\Framework\Model\AbstractModel an all condition are fulfilled.
*
* If read-only properties are set than $value mustn't have changes in them.
*
* @param AbstractModel $value
* @return bool
* @throws \InvalidArgumentException when $value is not instanceof \Magento\Framework\DataObject
* @api
*/
public function isValid($value)
{
$this->_clearMessages();
if (!$value instanceof AbstractModel) {
throw new \InvalidArgumentException('Instance of \\Magento\\Framework\\Model\\AbstractModel is expected.');
}
if ($this->_readOnlyProperties) {
if (!$value->hasDataChanges()) {
return true;
}
foreach ($this->_readOnlyProperties as $property) {
if ($this->_hasChanges($value->getData($property), $value->getOrigData($property))) {
$this->_messages[__CLASS__] = [(string) new \Magento\Framework\Phrase("Read-only property cannot be changed.")];
break;
}
}
}
return !count($this->_messages);
}
示例3: isModified
/**
* Check if object was modified
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return bool
*/
protected function isModified(\Magento\Framework\Model\AbstractModel $object)
{
return $object->hasDataChanges();
}
示例4: testSetDataChanges
/**
* Tests \Magento\Framework\Object->setDataChanges()
*/
public function testSetDataChanges()
{
$this->assertFalse($this->model->hasDataChanges());
$this->model->setDataChanges(true);
$this->assertTrue($this->model->hasDataChanges());
}