summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/src/Synchronization/GroupSynchronizationResponse.php')
-rw-r--r--MLEB/Translate/src/Synchronization/GroupSynchronizationResponse.php38
1 files changed, 29 insertions, 9 deletions
diff --git a/MLEB/Translate/src/Synchronization/GroupSynchronizationResponse.php b/MLEB/Translate/src/Synchronization/GroupSynchronizationResponse.php
index 83a58ef6..069be720 100644
--- a/MLEB/Translate/src/Synchronization/GroupSynchronizationResponse.php
+++ b/MLEB/Translate/src/Synchronization/GroupSynchronizationResponse.php
@@ -2,7 +2,11 @@
declare( strict_types = 1 );
-namespace MediaWiki\Extensions\Translate\Synchronization;
+namespace MediaWiki\Extension\Translate\Synchronization;
+
+use JsonSerializable;
+use MediaWiki\Extension\Translate\Utilities\Json\JsonUnserializable;
+use MediaWiki\Extension\Translate\Utilities\Json\JsonUnserializableTrait;
/**
* Class encapsulating the response returned by the GroupSynchronizationCache
@@ -11,30 +15,31 @@ namespace MediaWiki\Extensions\Translate\Synchronization;
* @license GPL-2.0-or-later
* @since 2020.06
*/
-class GroupSynchronizationResponse {
- /** @var array */
- private $remainingMessageKeys;
+class GroupSynchronizationResponse implements JsonSerializable, JsonUnserializable {
+ use JsonUnserializableTrait;
+ /** @var MessageUpdateParameter[] */
+ private $remainingMessages;
/** @var string */
private $groupId;
-
/** @var bool */
private $timeout;
public function __construct(
- string $groupId, array $remainingMessageKeys, bool $hasTimedOut
+ string $groupId, array $remainingMessages, bool $hasTimedOut
) {
$this->groupId = $groupId;
- $this->remainingMessageKeys = $remainingMessageKeys;
+ $this->remainingMessages = $remainingMessages;
$this->timeout = $hasTimedOut;
}
public function isDone(): bool {
- return $this->remainingMessageKeys === [];
+ return $this->remainingMessages === [];
}
+ /** @return MessageUpdateParameter[] */
public function getRemainingMessages(): array {
- return $this->remainingMessageKeys;
+ return $this->remainingMessages;
}
public function getGroupId(): string {
@@ -44,4 +49,19 @@ class GroupSynchronizationResponse {
public function hasTimedOut(): bool {
return $this->timeout;
}
+
+ /** @return mixed[] */
+ protected function toJsonArray(): array {
+ return get_object_vars( $this );
+ }
+
+ public static function newFromJsonArray( array $params ) {
+ return new self(
+ $params['groupId'],
+ $params['remainingMessages'],
+ $params['timeout']
+ );
+ }
}
+
+class_alias( GroupSynchronizationResponse::class, '\MediaWiki\Extensions\Translate\GroupSynchronizationResponse' );