<?php
require_once WPML_TM_PATH . '/inc/translation-jobs/helpers/wpml-update-translation-data-action.class.php';

class WPML_TM_Update_External_Translation_Data_Action extends WPML_TM_Update_Translation_Data_Action {

	protected function populate_prev_translation( $rid, array $package ) {
		list( $prev_job_id ) = $this->get_prev_job_data( $rid );

		$prev_translation = [];
		$prev_job         = $this->get_translation_job( $prev_job_id );
		if ( isset( $prev_job->original_doc_id ) ) {
			foreach ( $prev_job->elements as $element ) {
				$prev_translation[ $element->field_type ] = new WPML_TM_Translated_Field(
					$element->field_data,
					$element->field_data_translated,
					$element->field_finished
				);
			}
		}

		return apply_filters( 'wpml_tm_populate_prev_translation', $prev_translation, $package, $this->get_lang_by_rid( $rid ) );
	}
}
