Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
TtmServer.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\TtmServer;
5
7use MediaWiki\MediaWikiServices;
8use WikiPage;
9
18abstract class TtmServer {
19 protected array $config;
20
21 public function __construct( array $config ) {
22 $this->config = $config;
23 }
24
29 public static function sortSuggestions( array $suggestions ): array {
30 usort( $suggestions, static function ( array $a, array $b ) {
31 return $b['quality'] <=> $a['quality'];
32 } );
33
34 return $suggestions;
35 }
36
38 public static function onDelete( WikiPage $wikipage ): void {
39 $handle = new MessageHandle( $wikipage->getTitle() );
40 $job = TtmServerMessageUpdateJob::newJob( $handle, 'delete' );
41 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
42 }
43
45 public static function onChange( MessageHandle $handle ): void {
46 $job = TtmServerMessageUpdateJob::newJob( $handle, 'refresh' );
47 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
48 }
49
50 public static function onGroupChange( MessageHandle $handle, array $old ): void {
51 if ( $old === [] ) {
52 // Don't bother for newly added messages
53 return;
54 }
55
56 $job = TtmServerMessageUpdateJob::newJob( $handle, 'rebuild' );
57 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
58 }
59}
Class for pointing to messages, like Title class is for titles.
static onDelete(WikiPage $wikipage)
Hook: ArticleDeleteComplete.
Definition TtmServer.php:38
static onChange(MessageHandle $handle)
Called from TranslateEditAddons::onSave.
Definition TtmServer.php:45