Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
UpdateTranslatorActivityJob.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Extension\Translate\Statistics;
9
10use GenericParameterJob;
13
15class UpdateTranslatorActivityJob extends GenericTranslateJob implements GenericParameterJob {
16 public function __construct( array $params ) {
17 parent::__construct( 'UpdateTranslatorActivity', $params );
18 $this->removeDuplicates = true;
19 }
20
21 public static function newJobForLanguage( string $language ): self {
22 return new self( [ 'language' => $language ] );
23 }
24
25 public function run() {
26 $activity = Services::getInstance()->getTranslatorActivity();
27
28 try {
29 $activity->updateLanguage( $this->getParams()['language'] );
30 } catch ( StatisticsUnavailable $e ) {
31 $this->logInfo( $e->getMessage() );
32 // The job will be retried according to JobQueue configuration
33 return false;
34 }
35
36 return true;
37 }
38}
Minimal service container.
Definition Services.php:38