AddressSnapshot.php 981 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Model\ResourceModel\Db\VersionControl;
  7. use Magento\Framework\DataObject;
  8. use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot;
  9. class AddressSnapshot extends Snapshot
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function isModified(DataObject $entity)
  15. {
  16. $result = parent::isModified($entity);
  17. if (!$result
  18. && !$entity->getIsCustomerSaveTransaction()
  19. && $this->isAddressDefault($entity)
  20. ) {
  21. return true;
  22. }
  23. return $result;
  24. }
  25. /**
  26. * Checks if address has chosen as default and has had an id
  27. *
  28. * @param DataObject $entity
  29. * @return bool
  30. */
  31. private function isAddressDefault(DataObject $entity)
  32. {
  33. return $entity->getId() && ($entity->getIsDefaultBilling() || $entity->getIsDefaultShipping());
  34. }
  35. }