jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/379135 )

Change subject: Add add form summary
......................................................................


Add add form summary

Bug: T160525
Change-Id: I921f9e7356645ef9fb5dce4c6c1c771900c36cb4
---
M i18n/en.json
M i18n/qqq.json
M src/Api/AddForm.php
A src/Api/AddFormSummary.php
4 files changed, 51 insertions(+), 3 deletions(-)

Approvals:
  WMDE-leszek: Checked; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index 01bd811..0ad92b7 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -46,5 +46,6 @@
        "wikibase-lexeme-api-addform-representation-text-missing": "No 
representation string provided for representation at position $1",
        "wikibase-lexeme-api-addform-representation-language-missing": "No 
language provided for representation at position $1",
        "wikibase-lexeme-api-addform-grammatical-feature-itemid-invalid": 
"Invalid grammatical feature: $1",
-       "wikibase-lexeme-api-addform-grammatical-feature-not-item-id": "Not an 
item ID: $1"
+       "wikibase-lexeme-api-addform-grammatical-feature-not-item-id": "Not an 
item ID: $1",
+       "wikibase-lexeme-summary-add-form": "Added new form $3 with 
{{PLURAL:$1|representation|representations}}"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 9d4241c..ae942d6 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -51,5 +51,6 @@
        "wikibase-lexeme-api-addform-representation-text-missing": "API error 
description",
        "wikibase-lexeme-api-addform-representation-language-missing": "API 
error description",
        "wikibase-lexeme-api-addform-grammatical-feature-itemid-invalid": "API 
error description",
-       "wikibase-lexeme-api-addform-grammatical-feature-not-item-id": "API 
error description"
+       "wikibase-lexeme-api-addform-grammatical-feature-not-item-id": "API 
error description",
+       "wikibase-lexeme-summary-add-form": "{{wikibase summary 
messages|lexeme|Automatic edit summary generated when adding new Form to a 
Lexeme.}}\n\nParameters:\n* $1 - Number of representations of the form 
added.\n* $2 - ignore.\n* $3 - Form ID.\n\n{{Related|Wikibase-entity-summary}}"
 }
diff --git a/src/Api/AddForm.php b/src/Api/AddForm.php
index e80c206..ebf9242 100644
--- a/src/Api/AddForm.php
+++ b/src/Api/AddForm.php
@@ -113,9 +113,10 @@
 
                $lexeme = $this->entitySavingHelper->loadEntity( 
$request->getLexemeId() );
                $newForm = $request->addFormTo( $lexeme );
+               $summary = new AddFormSummary( $lexeme->getId(), $newForm );
                //FIXME: Handle failure
                //FIXME: ACHTUNG! attemptSaveEntity() uses 'baserevid' 
internally which should not be used!
-               $status = $this->entitySavingHelper->attemptSaveEntity( 
$lexeme, new Summary() );
+               $status = $this->entitySavingHelper->attemptSaveEntity( 
$lexeme, $summary );
 
                $apiResult = $this->getResult();
 
diff --git a/src/Api/AddFormSummary.php b/src/Api/AddFormSummary.php
new file mode 100644
index 0000000..f83e28f
--- /dev/null
+++ b/src/Api/AddFormSummary.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Wikibase\Lexeme\Api;
+
+use Wikibase\Lexeme\DataModel\Form;
+use Wikibase\Lexeme\DataModel\LexemeId;
+use Wikibase\Lib\FormatableSummary;
+
+class AddFormSummary implements FormatableSummary {
+       /**
+        * @var LexemeId
+        */
+       private $lexemeId;
+       /**
+        * @var Form
+        */
+       private $addedForm;
+
+       public function __construct( LexemeId $lexemeId, Form $addedForm ) {
+               $this->lexemeId = $lexemeId;
+               $this->addedForm = $addedForm;
+       }
+
+       public function getUserSummary() {
+               return null;
+       }
+
+       public function getLanguageCode() {
+               return null;
+       }
+
+       public function getMessageKey() {
+               /** @see "wikibase-lexeme-summary-add-form" message */
+               return 'add-form';
+       }
+
+       public function getCommentArgs() {
+               return [ $this->addedForm->getId()->getSerialization() ];
+       }
+
+       public function getAutoSummaryArgs() {
+               return array_values( 
$this->addedForm->getRepresentations()->toTextArray() );
+       }
+
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/379135
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I921f9e7356645ef9fb5dce4c6c1c771900c36cb4
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/WikibaseLexeme
Gerrit-Branch: master
Gerrit-Owner: Aleksey Bekh-Ivanov (WMDE) <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to