Adrian Lang has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/175684

Change subject: Use the same EntityInfo for JS and PHP
......................................................................

Use the same EntityInfo for JS and PHP

Change-Id: I8d315d039cd1145b430cc3bc108f5b9b6e1c5533
---
M repo/includes/EntityParserOutputGenerator.php
1 file changed, 4 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/84/175684/1

diff --git a/repo/includes/EntityParserOutputGenerator.php 
b/repo/includes/EntityParserOutputGenerator.php
index ec35036..9f55665 100644
--- a/repo/includes/EntityParserOutputGenerator.php
+++ b/repo/includes/EntityParserOutputGenerator.php
@@ -114,7 +114,7 @@
                $snaks = $entity->getAllSnaks();
 
                $usedEntityIds = 
$this->referencedEntitiesFinder->findSnakLinks( $snaks );
-               $entityInfo = $this->getEntityInfoForJsConfig( $usedEntityIds );
+               $entityInfo = $this->getEntityInfo( $usedEntityIds );
 
                $configVars = $this->configBuilder->build( $entity, $entityInfo 
);
                $parserOutput->addJsConfigVars( $configVars );
@@ -205,13 +205,12 @@
        }
 
        /**
-        * Fetches some basic entity information required for the entity view 
in JavaScript from a
-        * set of entity IDs.
+        * Fetches some basic entity information from a set of entity IDs.
         *
         * @param EntityId[] $entityIds
         * @return array obtained from EntityInfoBuilder::getEntityInfo
         */
-       private function getEntityInfoForJsConfig( array $entityIds ) {
+       private function getEntityInfo( array $entityIds ) {
                wfProfileIn( __METHOD__ );
 
                // @todo: use same instance of entity info, as for the view 
(see below)
@@ -238,27 +237,6 @@
        }
 
        /**
-        * @param EntityId[] $entityIds
-        * @return array obtained from EntityInfoBuilder::getEntityInfo
-        */
-       private function getEntityInfoForView( array $entityIds ) {
-               $propertyIds = array_filter( $entityIds, function ( EntityId 
$id ) {
-                       return $id->getEntityType() === Property::ENTITY_TYPE;
-               } );
-
-               $entityInfoBuilder = 
$this->entityInfoBuilderFactory->newEntityInfoBuilder( $propertyIds );
-
-               $entityInfoBuilder->removeMissing();
-
-               $entityInfoBuilder->collectTerms(
-                       array( 'label', 'description' ),
-                       array( $this->languageCode )
-               );
-
-               return $entityInfoBuilder->getEntityInfo();
-       }
-
-       /**
         * @param ParserOutput $parserOutput
         * @param SiteLinkList $siteLinkList
         */
@@ -282,7 +260,7 @@
                array $entityIds,
                $editable
        ) {
-               $entityInfo = $this->getEntityInfoForView( $entityIds );
+               $entityInfo = $this->getEntityInfo( $entityIds );
 
                $labelLookup = new LanguageFallbackLabelLookup(
                        new EntityInfoTermLookup( $entityInfo ),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d315d039cd1145b430cc3bc108f5b9b6e1c5533
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <adrian.l...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to