Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
TTMServer.php
Go to the documentation of this file.
1<?php
12use MediaWiki\MediaWikiServices;
13
20abstract class TTMServer {
22 protected $config;
23
25 public function __construct( array $config ) {
26 $this->config = $config;
27 }
28
33 public static function sortSuggestions( array $suggestions ) {
34 usort( $suggestions, static function ( $a, $b ) {
35 return $b['quality'] <=> $a['quality'];
36 } );
37
38 return $suggestions;
39 }
40
45 public static function onDelete( WikiPage $wikipage ) {
46 $handle = new MessageHandle( $wikipage->getTitle() );
47 $job = TTMServerMessageUpdateJob::newJob( $handle, 'delete' );
48 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
49 }
50
55 public static function onChange( MessageHandle $handle ) {
56 $job = TTMServerMessageUpdateJob::newJob( $handle, 'refresh' );
57 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
58 }
59
64 public static function onGroupChange( MessageHandle $handle, $old ) {
65 if ( $old === [] ) {
66 // Don't bother for newly added messages
67 return;
68 }
69
70 $job = TTMServerMessageUpdateJob::newJob( $handle, 'rebuild' );
71 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
72 }
73}
Class for pointing to messages, like Title class is for titles.
static newJob(MessageHandle $handle, $command)
Some general static methods for instantiating TTMServer and helpers.
Definition TTMServer.php:20
static sortSuggestions(array $suggestions)
Definition TTMServer.php:33
__construct(array $config)
Definition TTMServer.php:25
static onDelete(WikiPage $wikipage)
Hook: ArticleDeleteComplete.
Definition TTMServer.php:45
static onGroupChange(MessageHandle $handle, $old)
Definition TTMServer.php:64
static onChange(MessageHandle $handle)
Called from TranslateEditAddons::onSave.
Definition TTMServer.php:55