ActionMigrator.php
1 year ago
ActionScheduler_DBStoreMigrator.php
1 year ago
BatchFetcher.php
1 year ago
Config.php
1 year ago
Controller.php
1 year ago
DryRun_ActionMigrator.php
1 year ago
DryRun_LogMigrator.php
1 year ago
LogMigrator.php
1 year ago
Runner.php
1 year ago
Scheduler.php
1 year ago
Config.php
197 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 | /** |
| 21 | * Source store instance. |
| 22 | * |
| 23 | * @var ActionScheduler_Store |
| 24 | */ |
| 25 | private $source_store; |
| 26 | |
| 27 | /** |
| 28 | * Source logger instance. |
| 29 | * |
| 30 | * @var ActionScheduler_Logger |
| 31 | */ |
| 32 | private $source_logger; |
| 33 | |
| 34 | /** |
| 35 | * Destination store instance. |
| 36 | * |
| 37 | * @var ActionScheduler_Store |
| 38 | */ |
| 39 | private $destination_store; |
| 40 | |
| 41 | /** |
| 42 | * Destination logger instance. |
| 43 | * |
| 44 | * @var ActionScheduler_Logger |
| 45 | */ |
| 46 | private $destination_logger; |
| 47 | |
| 48 | /** |
| 49 | * Progress bar object. |
| 50 | * |
| 51 | * @var Action_Scheduler\WP_CLI\ProgressBar |
| 52 | */ |
| 53 | private $progress_bar; |
| 54 | |
| 55 | /** |
| 56 | * Flag indicating a dryrun. |
| 57 | * |
| 58 | * @var bool |
| 59 | */ |
| 60 | private $dry_run = false; |
| 61 | |
| 62 | /** |
| 63 | * Config constructor. |
| 64 | */ |
| 65 | public function __construct() { |
| 66 | |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Get the configured source store. |
| 71 | * |
| 72 | * @return ActionScheduler_Store |
| 73 | * @throws \RuntimeException When source store is not configured. |
| 74 | */ |
| 75 | public function get_source_store() { |
| 76 | if ( empty( $this->source_store ) ) { |
| 77 | throw new \RuntimeException( __( 'Source store must be configured before running a migration', 'woocommerce' ) ); |
| 78 | } |
| 79 | |
| 80 | return $this->source_store; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Set the configured source store. |
| 85 | * |
| 86 | * @param ActionScheduler_Store $store Source store object. |
| 87 | */ |
| 88 | public function set_source_store( Store $store ) { |
| 89 | $this->source_store = $store; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Get the configured source logger. |
| 94 | * |
| 95 | * @return ActionScheduler_Logger |
| 96 | * @throws \RuntimeException When source logger is not configured. |
| 97 | */ |
| 98 | public function get_source_logger() { |
| 99 | if ( empty( $this->source_logger ) ) { |
| 100 | throw new \RuntimeException( __( 'Source logger must be configured before running a migration', 'woocommerce' ) ); |
| 101 | } |
| 102 | |
| 103 | return $this->source_logger; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Set the configured source logger. |
| 108 | * |
| 109 | * @param ActionScheduler_Logger $logger Logger object. |
| 110 | */ |
| 111 | public function set_source_logger( Logger $logger ) { |
| 112 | $this->source_logger = $logger; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Get the configured destination store. |
| 117 | * |
| 118 | * @return ActionScheduler_Store |
| 119 | * @throws \RuntimeException When destination store is not configured. |
| 120 | */ |
| 121 | public function get_destination_store() { |
| 122 | if ( empty( $this->destination_store ) ) { |
| 123 | throw new \RuntimeException( __( 'Destination store must be configured before running a migration', 'woocommerce' ) ); |
| 124 | } |
| 125 | |
| 126 | return $this->destination_store; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Set the configured destination store. |
| 131 | * |
| 132 | * @param ActionScheduler_Store $store Action store object. |
| 133 | */ |
| 134 | public function set_destination_store( Store $store ) { |
| 135 | $this->destination_store = $store; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Get the configured destination logger. |
| 140 | * |
| 141 | * @return ActionScheduler_Logger |
| 142 | * @throws \RuntimeException When destination logger is not configured. |
| 143 | */ |
| 144 | public function get_destination_logger() { |
| 145 | if ( empty( $this->destination_logger ) ) { |
| 146 | throw new \RuntimeException( __( 'Destination logger must be configured before running a migration', 'woocommerce' ) ); |
| 147 | } |
| 148 | |
| 149 | return $this->destination_logger; |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Set the configured destination logger. |
| 154 | * |
| 155 | * @param ActionScheduler_Logger $logger Logger object. |
| 156 | */ |
| 157 | public function set_destination_logger( Logger $logger ) { |
| 158 | $this->destination_logger = $logger; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Get flag indicating whether it's a dry run. |
| 163 | * |
| 164 | * @return bool |
| 165 | */ |
| 166 | public function get_dry_run() { |
| 167 | return $this->dry_run; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Set flag indicating whether it's a dry run. |
| 172 | * |
| 173 | * @param bool $dry_run Dry run toggle. |
| 174 | */ |
| 175 | public function set_dry_run( $dry_run ) { |
| 176 | $this->dry_run = (bool) $dry_run; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Get progress bar object. |
| 181 | * |
| 182 | * @return ActionScheduler\WPCLI\ProgressBar |
| 183 | */ |
| 184 | public function get_progress_bar() { |
| 185 | return $this->progress_bar; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Set progress bar object. |
| 190 | * |
| 191 | * @param ActionScheduler\WPCLI\ProgressBar $progress_bar Progress bar object. |
| 192 | */ |
| 193 | public function set_progress_bar( ProgressBar $progress_bar ) { |
| 194 | $this->progress_bar = $progress_bar; |
| 195 | } |
| 196 | } |
| 197 |