first commit
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
use function WPML\FP\invoke;
|
||||
|
||||
class WPML_TM_ATE_Job_Repository {
|
||||
|
||||
/** @var WPML_TM_Jobs_Repository */
|
||||
private $job_repository;
|
||||
|
||||
public function __construct( WPML_TM_Jobs_Repository $job_repository ) {
|
||||
$this->job_repository = $job_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $includeManualAndLongstandingJobs
|
||||
*
|
||||
* @return WPML_TM_Jobs_Collection
|
||||
*/
|
||||
public function get_jobs_to_sync( $includeManualAndLongstandingJobs = true ) {
|
||||
$searchParams = $this->getSearchParamsPrototype();
|
||||
$searchParams->set_status( [ ICL_TM_WAITING_FOR_TRANSLATOR, ICL_TM_IN_PROGRESS ] );
|
||||
|
||||
$searchParams->set_exclude_manual( ! $includeManualAndLongstandingJobs );
|
||||
$searchParams->set_exclude_longstanding( ! $includeManualAndLongstandingJobs );
|
||||
|
||||
return $this->job_repository
|
||||
->get( $searchParams )
|
||||
->filter( invoke( 'is_ate_job' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ateJobIds
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function increment_ate_sync_count( array $ateJobIds ) {
|
||||
return $this->job_repository->increment_ate_sync_count( $ateJobIds );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WPML_TM_Jobs_Collection
|
||||
*/
|
||||
public function get_jobs_to_retry() {
|
||||
$searchParams = $this->getSearchParamsPrototype();
|
||||
$searchParams->set_status( [ ICL_TM_ATE_NEEDS_RETRY ] );
|
||||
|
||||
return $this->job_repository
|
||||
->get( $searchParams )
|
||||
->filter( invoke( 'is_ate_job' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WPML_TM_Jobs_Search_Params
|
||||
*/
|
||||
private function getSearchParamsPrototype() {
|
||||
$searchParams = new WPML_TM_Jobs_Search_Params();
|
||||
$searchParams->set_scope( WPML_TM_Jobs_Search_Params::SCOPE_LOCAL );
|
||||
$searchParams->set_job_types( [
|
||||
WPML_TM_Job_Entity::POST_TYPE,
|
||||
WPML_TM_Job_Entity::PACKAGE_TYPE,
|
||||
WPML_TM_Job_Entity::STRING_BATCH,
|
||||
] );
|
||||
|
||||
return $searchParams;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class WPML_TM_ATE_Models_Job_Create {
|
||||
/** @var int */
|
||||
public $id;
|
||||
/** @var int */
|
||||
public $deadline;
|
||||
/** @var WPML_TM_ATE_Models_Job_File */
|
||||
public $file;
|
||||
/** @var bool */
|
||||
public $notify_enabled;
|
||||
/** @var string */
|
||||
public $notify_url;
|
||||
/** @var int */
|
||||
public $source_id;
|
||||
/** @var string */
|
||||
public $permalink;
|
||||
/** @var string */
|
||||
public $site_identifier;
|
||||
/** @var WPML_TM_ATE_Models_Language */
|
||||
public $source_language;
|
||||
/** @var WPML_TM_ATE_Models_Language */
|
||||
public $target_language;
|
||||
/** @var string */
|
||||
public $ate_ams_console_url;
|
||||
/** @var int */
|
||||
public $existing_ate_id;
|
||||
|
||||
/**
|
||||
* WPML_TM_ATE_Models_Job_Create constructor.
|
||||
*
|
||||
* @param array $args
|
||||
*
|
||||
* @throws \Auryn\InjectionException
|
||||
*/
|
||||
public function __construct( array $args = array() ) {
|
||||
foreach ( $args as $key => $value ) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
if ( ! $this->file ) {
|
||||
$this->file = new WPML_TM_ATE_Models_Job_File();
|
||||
}
|
||||
if ( ! $this->source_language ) {
|
||||
$this->source_language = new WPML_TM_ATE_Models_Language();
|
||||
}
|
||||
if ( ! $this->target_language ) {
|
||||
$this->target_language = new WPML_TM_ATE_Models_Language();
|
||||
}
|
||||
|
||||
$this->ate_ams_console_url = wpml_tm_get_ams_ate_console_url();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class WPML_TM_ATE_Models_Job_File {
|
||||
public $content;
|
||||
public $name;
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* WPML_TM_ATE_Models_Job_File constructor.
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct( array $args = array() ) {
|
||||
foreach ( $args as $key => $value ) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class WPML_TM_ATE_Models_Language {
|
||||
public $code;
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct( $code = null, $name = null ) {
|
||||
$this->code = $code;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class WPML_TM_Job_Created {
|
||||
public $job_id;
|
||||
public $rid;
|
||||
public $translation_service;
|
||||
public $translator_id;
|
||||
public $translation_package;
|
||||
public $batch_options;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* WPML_TM_Job_Created constructor.
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct( array $args ) {
|
||||
foreach ( $args as $key => $value ) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user