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