22 protected $hookContainer;
24 protected $loadBalancer;
26 public function __construct( ILoadBalancer $loadBalancer, HookContainer $hookContainer ) {
27 $this->loadBalancer = $loadBalancer;
28 $this->hookContainer = $hookContainer;
33 $dbw = $this->loadBalancer->getMaintenanceConnectionRef( DB_PRIMARY );
34 $table =
'translate_groupreviews';
38 'tgr_group' => $group->
getId(),
42 return $dbw->selectField( $table, $field, $conds, __METHOD__ );
45 public function changeState(
MessageGroup $group,
string $code,
string $newState, User $user ): bool {
46 $currentState = self::
getState( $group, $code );
47 if ( $currentState === $newState ) {
51 $table =
'translate_groupreviews';
52 $index = [
'tgr_group',
'tgr_lang' ];
54 'tgr_group' => $group->
getId(),
56 'tgr_state' => $newState,
58 $dbw = $this->loadBalancer->getMaintenanceConnectionRef( DB_PRIMARY );
59 $dbw->replace( $table, [ $index ], $row, __METHOD__ );
61 $entry =
new ManualLogEntry(
'translationreview',
'group' );
62 $entry->setPerformer( $user );
63 $entry->setTarget( SpecialPage::getTitleFor(
'Translate', $group->
getId() ) );
66 $entry->setParameters( [
67 '4::language' => $code,
68 '5::group-label' => $group->
getLabel(),
69 '6::old-state' => $currentState,
70 '7::new-state' => $newState,
73 $logid = $entry->insert();
74 $entry->publish( $logid );
76 $this->hookContainer->run(
'TranslateEventMessageGroupStateChange',
77 [ $group, $code, $currentState, $newState ] );