Hoo man has submitted this change and it was merged.
Change subject: Simplify SnakFinder
......................................................................
Simplify SnakFinder
Change-Id: I0b17944523d7f297b2ae9fd036af3267e98ddc15
---
M client/includes/DataAccess/PropertyParserFunction/SnaksFinder.php
M composer.json
2 files changed, 6 insertions(+), 21 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/includes/DataAccess/PropertyParserFunction/SnaksFinder.php
b/client/includes/DataAccess/PropertyParserFunction/SnaksFinder.php
index d85204b..c318089 100644
--- a/client/includes/DataAccess/PropertyParserFunction/SnaksFinder.php
+++ b/client/includes/DataAccess/PropertyParserFunction/SnaksFinder.php
@@ -37,8 +37,6 @@
* @param PropertyId $propertyId - the PropertyId for which we want the
formatted Snaks
* @param string $languageCode - language to render values
*
- * TODO: use SnakList instead of array of Snaks
- *
* @return Snak[]
*/
public function findSnaks( EntityId $entityId, PropertyId $propertyId,
$languageCode ) {
@@ -52,40 +50,27 @@
return array();
}
- // We only want the best claims over here, so that we only show
the most
- // relevant information.
- $bestStatements = $this->getBestStatementsForProperty( $entity,
$propertyId );
+ $snaks = $this->getBestMainSnaksForProperty( $entity,
$propertyId );
- if ( empty( $bestStatements ) ) {
+ if ( empty( $snaks ) ) {
wfDebugLog( __CLASS__, __METHOD__ . ': no claims
found.' );
wfProfileOut( __METHOD__ );
return array();
}
-
- $snaks = array_map(
- function( Statement $statement ) {
- return $statement->getMainSnak();
- },
- $bestStatements
- );
wfProfileOut( __METHOD__ );
return $snaks;
}
/**
- * Returns such Claims from $entity that have a main Snak for the
property that
- * is specified by $propertyId.
- *
* @param EntityDocument $entity The Entity from which to get the clams
* @param PropertyId $propertyId
*
- * @return Statement[]
+ * @return Snak[]
*/
- private function getBestStatementsForProperty( EntityDocument $entity,
PropertyId $propertyId ) {
+ private function getBestMainSnaksForProperty( EntityDocument $entity,
PropertyId $propertyId ) {
if ( $entity instanceof StatementListProvider ) {
- $bestStatementsFinder = new BestStatementsFinder(
$entity->getStatements() );
- return
$bestStatementsFinder->getBestStatementsForProperty( $propertyId );
+ return $entity->getStatements()->getWithPropertyId(
$propertyId )->getBestStatements()->getMainSnaks();
}
return array();
diff --git a/composer.json b/composer.json
index 9fd36b9..063d098 100644
--- a/composer.json
+++ b/composer.json
@@ -35,7 +35,7 @@
"data-values/javascript": "~0.6.0",
"data-values/value-view": "~0.8.1",
- "wikibase/data-model": "~2.3",
+ "wikibase/data-model": "~2.4",
"wikibase/data-model-javascript": "~1.0",
"wikibase/data-model-serialization": "~1.2",
"wikibase/internal-serialization": "~1.3",
--
To view, visit https://gerrit.wikimedia.org/r/175316
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0b17944523d7f297b2ae9fd036af3267e98ddc15
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits