本文整理汇总了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());
}