WordPress at a glance
class is not described

Action_Scheduler\Migration

LogMigrator{} WC 3.0.0

Class LogMigrator

No Hooks.

Return

null. Nothing.

Usage

$LogMigrator = new LogMigrator();
// use class methods

Methods

  1. __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger )
  2. migrate( $source_action_id, $destination_action_id )

Notes

  • Package: Action_Scheduler\Migration

Changelog

Since 3.0.0 Introduced.

Code of LogMigrator{} WC 5.3.0

<?php
class LogMigrator {
	/** @var ActionScheduler_Logger */
	private $source;

	/** @var ActionScheduler_Logger */
	private $destination;

	/**
	 * ActionMigrator constructor.
	 *
	 * @param ActionScheduler_Logger $source_logger Source logger object.
	 * @param ActionScheduler_Logger $destination_Logger Destination logger object.
	 */
	public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) {
		$this->source      = $source_logger;
		$this->destination = $destination_Logger;
	}

	/**
	 * Migrate an action log.
	 *
	 * @param int $source_action_id Source logger object.
	 * @param int $destination_action_id Destination logger object.
	 */
	public function migrate( $source_action_id, $destination_action_id ) {
		$logs = $this->source->get_logs( $source_action_id );
		foreach ( $logs as $log ) {
			if ( $log->get_action_id() == $source_action_id ) {
				$this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() );
			}
		}
	}
}