State.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\CatalogSearch\Model\Indexer\Scope;
  7. /**
  8. * This class represents state that defines which table should be used during indexation process
  9. *
  10. * There are two possible states:
  11. * - use_temporary_table
  12. * - use_main_table
  13. *
  14. * The 'use_main_table' state means that default indexer table should be used.
  15. *
  16. * The 'use_temporary_table' state is an opposite for 'use_main_table'
  17. * which means that default indexer table should be left unchanged during indexation
  18. * and temporary table should be used instead.
  19. */
  20. class State
  21. {
  22. const USE_TEMPORARY_INDEX = 'use_temporary_table';
  23. const USE_REGULAR_INDEX = 'use_main_table';
  24. /**
  25. * @var string
  26. */
  27. private $state = self::USE_REGULAR_INDEX;
  28. /**
  29. * Set the state to use temporary Index
  30. *
  31. * @return void
  32. */
  33. public function useTemporaryIndex()
  34. {
  35. $this->state = self::USE_TEMPORARY_INDEX;
  36. }
  37. /**
  38. * Set the state to use regular Index
  39. *
  40. * @return void
  41. */
  42. public function useRegularIndex()
  43. {
  44. $this->state = self::USE_REGULAR_INDEX;
  45. }
  46. /**
  47. * Get state.
  48. *
  49. * @return string
  50. */
  51. public function getState()
  52. {
  53. return $this->state;
  54. }
  55. }