Flag.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Synchronize process status flag class
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\MediaStorage\Model\File\Storage;
  12. /**
  13. * @api
  14. * @since 100.0.2
  15. */
  16. class Flag extends \Magento\Framework\Flag
  17. {
  18. /**
  19. * There was no synchronization
  20. */
  21. const STATE_INACTIVE = 0;
  22. /**
  23. * Synchronize process is active
  24. */
  25. const STATE_RUNNING = 1;
  26. /**
  27. * Synchronization finished
  28. */
  29. const STATE_FINISHED = 2;
  30. /**
  31. * Synchronization finished and notify message was formed
  32. */
  33. const STATE_NOTIFIED = 3;
  34. /**
  35. * Flag time to life in seconds
  36. */
  37. const FLAG_TTL = 300;
  38. /**
  39. * Synchronize flag code
  40. *
  41. * @var string
  42. */
  43. protected $_flagCode = 'synchronize';
  44. /**
  45. * Pass error to flag
  46. *
  47. * @param \Exception $e
  48. * @return $this
  49. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  50. */
  51. public function passError(\Exception $e)
  52. {
  53. $data = $this->getFlagData();
  54. if (!is_array($data)) {
  55. $data = [];
  56. }
  57. $data['has_errors'] = true;
  58. $this->setFlagData($data);
  59. return $this;
  60. }
  61. }