Geen omschrijving

Config.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. namespace Action_Scheduler\Migration;
  3. use Action_Scheduler\WP_CLI\ProgressBar;
  4. use ActionScheduler_Logger as Logger;
  5. use ActionScheduler_Store as Store;
  6. /**
  7. * Class Config
  8. *
  9. * @package Action_Scheduler\Migration
  10. *
  11. * @since 3.0.0
  12. *
  13. * A config builder for the ActionScheduler\Migration\Runner class
  14. */
  15. class Config {
  16. /** @var ActionScheduler_Store */
  17. private $source_store;
  18. /** @var ActionScheduler_Logger */
  19. private $source_logger;
  20. /** @var ActionScheduler_Store */
  21. private $destination_store;
  22. /** @var ActionScheduler_Logger */
  23. private $destination_logger;
  24. /** @var Progress bar */
  25. private $progress_bar;
  26. /** @var bool */
  27. private $dry_run = false;
  28. /**
  29. * Config constructor.
  30. */
  31. public function __construct() {
  32. }
  33. /**
  34. * Get the configured source store.
  35. *
  36. * @return ActionScheduler_Store
  37. */
  38. public function get_source_store() {
  39. if ( empty( $this->source_store ) ) {
  40. throw new \RuntimeException( __( 'Source store must be configured before running a migration', 'woocommerce' ) );
  41. }
  42. return $this->source_store;
  43. }
  44. /**
  45. * Set the configured source store.
  46. *
  47. * @param ActionScheduler_Store $store Source store object.
  48. */
  49. public function set_source_store( Store $store ) {
  50. $this->source_store = $store;
  51. }
  52. /**
  53. * Get the configured source loger.
  54. *
  55. * @return ActionScheduler_Logger
  56. */
  57. public function get_source_logger() {
  58. if ( empty( $this->source_logger ) ) {
  59. throw new \RuntimeException( __( 'Source logger must be configured before running a migration', 'woocommerce' ) );
  60. }
  61. return $this->source_logger;
  62. }
  63. /**
  64. * Set the configured source logger.
  65. *
  66. * @param ActionScheduler_Logger $logger
  67. */
  68. public function set_source_logger( Logger $logger ) {
  69. $this->source_logger = $logger;
  70. }
  71. /**
  72. * Get the configured destination store.
  73. *
  74. * @return ActionScheduler_Store
  75. */
  76. public function get_destination_store() {
  77. if ( empty( $this->destination_store ) ) {
  78. throw new \RuntimeException( __( 'Destination store must be configured before running a migration', 'woocommerce' ) );
  79. }
  80. return $this->destination_store;
  81. }
  82. /**
  83. * Set the configured destination store.
  84. *
  85. * @param ActionScheduler_Store $store
  86. */
  87. public function set_destination_store( Store $store ) {
  88. $this->destination_store = $store;
  89. }
  90. /**
  91. * Get the configured destination logger.
  92. *
  93. * @return ActionScheduler_Logger
  94. */
  95. public function get_destination_logger() {
  96. if ( empty( $this->destination_logger ) ) {
  97. throw new \RuntimeException( __( 'Destination logger must be configured before running a migration', 'woocommerce' ) );
  98. }
  99. return $this->destination_logger;
  100. }
  101. /**
  102. * Set the configured destination logger.
  103. *
  104. * @param ActionScheduler_Logger $logger
  105. */
  106. public function set_destination_logger( Logger $logger ) {
  107. $this->destination_logger = $logger;
  108. }
  109. /**
  110. * Get flag indicating whether it's a dry run.
  111. *
  112. * @return bool
  113. */
  114. public function get_dry_run() {
  115. return $this->dry_run;
  116. }
  117. /**
  118. * Set flag indicating whether it's a dry run.
  119. *
  120. * @param bool $dry_run
  121. */
  122. public function set_dry_run( $dry_run ) {
  123. $this->dry_run = (bool) $dry_run;
  124. }
  125. /**
  126. * Get progress bar object.
  127. *
  128. * @return ActionScheduler\WPCLI\ProgressBar
  129. */
  130. public function get_progress_bar() {
  131. return $this->progress_bar;
  132. }
  133. /**
  134. * Set progress bar object.
  135. *
  136. * @param ActionScheduler\WPCLI\ProgressBar $progress_bar
  137. */
  138. public function set_progress_bar( ProgressBar $progress_bar ) {
  139. $this->progress_bar = $progress_bar;
  140. }
  141. }