Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MoveTranslatableBundleJob.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\MessageGroupProcessing;
5
6use Job;
9use MediaWiki\MediaWikiServices;
10use Title;
11use User;
12
20class MoveTranslatableBundleJob extends Job {
22 private $bundleMover;
23
24 public static function newJob(
25 Title $source,
26 Title $target,
27 array $moves,
28 string $summary,
29 User $performer
30 ): self {
31 $params = [
32 'source' => $source->getPrefixedText(),
33 'target' => $target->getPrefixedText(),
34 'moves' => $moves,
35 'summary' => $summary,
36 'performer' => $performer->getName(),
37 ];
38
39 $self = new self( $target, $params );
40
41 return $self;
42 }
43
44 public function __construct( Title $title, array $params = [] ) {
45 parent::__construct( 'MoveTranslatableBundleJob', $title, $params );
46 $this->bundleMover = Services::getInstance()->getTranslatableBundleMover();
47 }
48
49 public function run() {
50 $sourceTitle = Title::newFromText( $this->params['source'] );
51 $targetTitle = Title::newFromText( $this->params['target'] );
52
53 $userFactory = MediaWikiServices::getInstance()->getUserFactory();
54 $performer = $userFactory->newFromName( $this->params['performer'] );
55
56 $this->bundleMover->moveSynchronously(
57 $sourceTitle,
58 $targetTitle,
59 $this->params['moves'],
60 $performer,
61 $this->params['summary']
62 );
63
64 return true;
65 }
66}
Contains the core logic to validate and move translatable bundles.
Minimal service container.
Definition Services.php:38