jenkins-bot has submitted this change and it was merged.

Change subject: Use EntityDocument in SpecialNewEntity and derivatives
......................................................................


Use EntityDocument in SpecialNewEntity and derivatives

Change-Id: I5c81219bba7fe393e67971ef4c8bc2bd53c1155a
---
M repo/includes/specials/SpecialNewEntity.php
M repo/includes/specials/SpecialNewItem.php
M repo/includes/specials/SpecialNewProperty.php
3 files changed, 24 insertions(+), 20 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/specials/SpecialNewEntity.php 
b/repo/includes/specials/SpecialNewEntity.php
index 1f6dac4..bfc53d2 100644
--- a/repo/includes/specials/SpecialNewEntity.php
+++ b/repo/includes/specials/SpecialNewEntity.php
@@ -2,17 +2,19 @@
 
 namespace Wikibase\Repo\Specials;
 
-use HTMLForm;
 use Html;
+use HTMLForm;
+use InvalidArgumentException;
 use Language;
 use Status;
 use Wikibase\CopyrightMessageBuilder;
-use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityDocument;
+use Wikibase\DataModel\Term\FingerprintHolder;
 use Wikibase\Repo\WikibaseRepo;
 use Wikibase\Summary;
 
 /**
- * Page for creating new Wikibase entities.
+ * Page for creating new Wikibase entities that contain a Fingerprint.
  *
  * @since 0.1
  * @licence GNU GPL v2+
@@ -199,7 +201,7 @@
        /**
         * @since 0.1
         *
-        * @return Entity Created entity of correct subtype
+        * @return EntityDocument Created entity of correct subtype
         */
        abstract protected function createEntity();
 
@@ -208,21 +210,22 @@
         *
         * @since 0.1
         *
-        * @param Entity &$entity
+        * @param EntityDocument &$entity
         *
         * @return Status
         */
-       protected function modifyEntity( Entity &$entity ) {
+       protected function modifyEntity( EntityDocument &$entity ) {
+               if ( !( $entity instanceof FingerprintHolder ) ) {
+                       throw new InvalidArgumentException( '$entity must be a 
FingerprintHolder' );
+               }
+
                $contentLanguageCode = $this->contentLanguage->getCode();
-               if ( $this->label !== '' ) {
-                       $entity->setLabel( $contentLanguageCode, $this->label );
-               }
-               if ( $this->description !== '' ) {
-                       $entity->setDescription( $contentLanguageCode, 
$this->description );
-               }
-               if ( count( $this->aliases ) !== 0 ) {
-                       $entity->setAliases( $contentLanguageCode, 
$this->aliases );
-               }
+               $fingerprint = $entity->getFingerprint();
+
+               $fingerprint->setLabel( $contentLanguageCode, $this->label );
+               $fingerprint->setDescription( $contentLanguageCode, 
$this->description );
+               $fingerprint->setAliasGroup( $contentLanguageCode, 
$this->aliases );
+
                return Status::newGood();
        }
 
diff --git a/repo/includes/specials/SpecialNewItem.php 
b/repo/includes/specials/SpecialNewItem.php
index 10d6483..bfd05e4 100644
--- a/repo/includes/specials/SpecialNewItem.php
+++ b/repo/includes/specials/SpecialNewItem.php
@@ -5,6 +5,7 @@
 use InvalidArgumentException;
 use Status;
 use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityDocument;
 use Wikibase\DataModel\Entity\Item;
 
 /**
@@ -59,12 +60,12 @@
        /**
         * @see SpecialNewEntity::modifyEntity
         *
-        * @param Entity $item
+        * @param EntityDocument $item
         *
         * @throws InvalidArgumentException
         * @return Status
         */
-       protected function modifyEntity( Entity &$item ) {
+       protected function modifyEntity( EntityDocument &$item ) {
                $status = parent::modifyEntity( $item );
 
                if ( $this->site !== null && $this->page !== null ) {
diff --git a/repo/includes/specials/SpecialNewProperty.php 
b/repo/includes/specials/SpecialNewProperty.php
index ccce096..f02563c 100644
--- a/repo/includes/specials/SpecialNewProperty.php
+++ b/repo/includes/specials/SpecialNewProperty.php
@@ -4,7 +4,7 @@
 
 use InvalidArgumentException;
 use Status;
-use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityDocument;
 use Wikibase\DataModel\Entity\Property;
 use Wikibase\DataTypeSelector;
 use Wikibase\Repo\WikibaseRepo;
@@ -64,12 +64,12 @@
        /**
         * @see SpecialNewEntity::modifyEntity
         *
-        * @param Entity $property
+        * @param EntityDocument $property
         *
         * @throws InvalidArgumentException
         * @return Status
         */
-       protected function modifyEntity( Entity &$property ) {
+       protected function modifyEntity( EntityDocument &$property ) {
                $status = parent::modifyEntity( $property );
 
                if ( $this->dataType !== '' ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5c81219bba7fe393e67971ef4c8bc2bd53c1155a
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Bene <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Bene <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to