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
LogMigrator.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Action_Scheduler\Migration; |
| 5 | |
| 6 | use ActionScheduler_Logger; |
| 7 | |
| 8 | /** |
| 9 | * Class LogMigrator |
| 10 | * |
| 11 | * @package Action_Scheduler\Migration |
| 12 | * |
| 13 | * @since 3.0.0 |
| 14 | * |
| 15 | * @codeCoverageIgnore |
| 16 | */ |
| 17 | class LogMigrator { |
| 18 | /** |
| 19 | * Source logger instance. |
| 20 | * |
| 21 | * @var ActionScheduler_Logger |
| 22 | */ |
| 23 | private $source; |
| 24 | |
| 25 | /** |
| 26 | * Destination logger instance. |
| 27 | * |
| 28 | * @var ActionScheduler_Logger |
| 29 | */ |
| 30 | private $destination; |
| 31 | |
| 32 | /** |
| 33 | * ActionMigrator constructor. |
| 34 | * |
| 35 | * @param ActionScheduler_Logger $source_logger Source logger object. |
| 36 | * @param ActionScheduler_Logger $destination_logger Destination logger object. |
| 37 | */ |
| 38 | public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_logger ) { |
| 39 | $this->source = $source_logger; |
| 40 | $this->destination = $destination_logger; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Migrate an action log. |
| 45 | * |
| 46 | * @param int $source_action_id Source logger object. |
| 47 | * @param int $destination_action_id Destination logger object. |
| 48 | */ |
| 49 | public function migrate( $source_action_id, $destination_action_id ) { |
| 50 | $logs = $this->source->get_logs( $source_action_id ); |
| 51 | |
| 52 | foreach ( $logs as $log ) { |
| 53 | if ( absint( $log->get_action_id() ) === absint( $source_action_id ) ) { |
| 54 | $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 |