Bene has uploaded a new change for review.
https://gerrit.wikimedia.org/r/268967
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, 25 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/67/268967/1
diff --git a/repo/includes/specials/SpecialNewEntity.php
b/repo/includes/specials/SpecialNewEntity.php
index 1f6dac4..e3be6b3 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 have 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,23 @@
*
* @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 has to 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 );
+ $entity->setFingerprint( $fingerprint );
+
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: newchange
Gerrit-Change-Id: I5c81219bba7fe393e67971ef4c8bc2bd53c1155a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Bene <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits