Source
<?php
namespace WPML\ST\Batch\Translation;
use phpDocumentor\Reflection\Types\Callable_;
use WPML\Collect\Support\Traits\Macroable;
use WPML\FP\Fns;
use WPML\FP\Logic;
use WPML\FP\Obj;
use WPML\FP\Str;
use WPML\FP\Wrapper;
use WPML\ST\API\Fns as ST_API;
use function WPML\Container\make;
use function WPML\FP\curryN;
use function WPML\FP\invoke;
use function WPML\FP\pipe;
use function WPML\FP\spreadArgs;
/**
* Class StringTranslations
*
* @package WPML\ST\Batch\Translation
* @method static callable|void save( ...$element_type_prefix, ...$job, ...$decoder ) :: string → object → ( string → string → string ) → void
* @method static callable|void addExisting( ...$prevTranslations, ...$package, ...$lang ) :: [WPML_TM_Translated_Field] → object → string → [WPML_TM_Translated_Field]
* @method static callable|bool isTranslated( ...$field ) :: object → bool
* @method static callable|bool isBatchId( ...$str ) :: string → bool
* @method static callable|bool isBatchField( ...$field ) :: object → bool
* @method static callable|string decodeStringId( ...$str ) :: string → string
* @method static callable|void markTranslationsAsInProgress( ...$getJobStatus, ...$hasTranslation, ...$addTranslation, ...$post, ...$element) :: callable -> callable -> callable -> WPML_TM_Translation_Batch_Element -> \stdClass -> void
* @method static callable|void cancelTranslations(...$job) :: \WPML_TM_Job_Entity -> void
* @method static callable|void updateStatus(...$element_type_prefix, ...$job) :: string -> \stdClass -> void
*/
class StringTranslations {
use Macroable;
public static function init() {
self::macro( 'isBatchId', Str::startsWith( Module::STRING_ID_PREFIX ) );
self::macro( 'isTranslated', Obj::prop( 'field_translate' ) );
self::macro(
'isBatchField',
curryN(
1,
function( $field ) {
return self::isBatchId( Obj::prop( 'field_type', $field ) );
}
)
);
self::macro( 'decodeStringId', Str::replace( Module::STRING_ID_PREFIX, '' ) );
self::macro(
'save',
curryN(
3,
function ( $element_type_prefix, $job, callable $decoder ) {
if ( $element_type_prefix === 'st-batch' ) {
// $decodeField :: field → string
$decodeField = pipe(