Addshore has submitted this change and it was merged.

Change subject: Rename PropertyInfo to more generic EntityInfo
......................................................................


Rename PropertyInfo to more generic EntityInfo

This is a direct follow-up to patch
I912882b09d302f8c74b1138b1aa3ab807d19f094. Yes, I messed that up
by choosing the wrong name. Don't ask. ;-)

Change-Id: I46bdbd049521e10f8cb7a9bfbf13ad3ad96302f5
---
M repo/includes/ClaimHtmlGenerator.php
M repo/includes/EntityView.php
M repo/includes/view/SnakHtmlGenerator.php
M repo/tests/phpunit/includes/view/SnakHtmlGeneratorTest.php
4 files changed, 42 insertions(+), 38 deletions(-)

Approvals:
  WikidataJenkins: Verified
  Addshore: Looks good to me, approved
  jenkins-bot: Checked



diff --git a/repo/includes/ClaimHtmlGenerator.php 
b/repo/includes/ClaimHtmlGenerator.php
index aa4fd79..7e578ea 100644
--- a/repo/includes/ClaimHtmlGenerator.php
+++ b/repo/includes/ClaimHtmlGenerator.php
@@ -49,17 +49,17 @@
         * @since 0.4
         *
         * @param Claim $claim the claim to render
-        * @param array[] $propertyInfo
+        * @param array[] $entityInfo
         * @param null|string $editSectionHtml has the html for the edit section
         *
         * @return string
         */
-       public function getHtmlForClaim( Claim $claim, array $propertyInfo, 
$editSectionHtml = null ) {
+       public function getHtmlForClaim( Claim $claim, array $entityInfo, 
$editSectionHtml = null ) {
                wfProfileIn( __METHOD__ );
 
                $mainSnakHtml = $this->snakHtmlGenerator->getSnakHtml(
                        $claim->getMainSnak(),
-                       $propertyInfo,
+                       $entityInfo,
                        false
                );
 
@@ -67,7 +67,7 @@
                        $claimHtml = wfTemplate( 'wb-claim',
                                $claim->getGuid(),
                                $mainSnakHtml,
-                               $this->getHtmlForQualifiers( 
$claim->getQualifiers(), $propertyInfo ),
+                               $this->getHtmlForQualifiers( 
$claim->getQualifiers(), $entityInfo ),
                                $editSectionHtml
                        );
                } else {
@@ -94,14 +94,14 @@
 
                        $referencesHtml = $this->getHtmlForReferences(
                                $claim->getReferences(),
-                               $propertyInfo
+                               $entityInfo
                        );
 
                        $claimHtml = wfTemplate( 'wb-statement',
                                $rankHtml,
                                $claim->getGuid(),
                                $mainSnakHtml,
-                               $this->getHtmlForQualifiers( 
$claim->getQualifiers(), $propertyInfo ),
+                               $this->getHtmlForQualifiers( 
$claim->getQualifiers(), $entityInfo ),
                                $editSectionHtml,
                                $referencesHeading,
                                $referencesHtml
@@ -116,11 +116,11 @@
         * Generates and returns the HTML representing a claim's qualifiers.
         *
         * @param Snaks $qualifiers
-        * @param array[] $propertyInfo
+        * @param array[] $entityInfo
         *
         * @return string
         */
-       protected function getHtmlForQualifiers( Snaks $qualifiers, array 
$propertyInfo ) {
+       protected function getHtmlForQualifiers( Snaks $qualifiers, array 
$entityInfo ) {
                $qualifiersByProperty = new ByPropertyIdArray( $qualifiers );
                $qualifiersByProperty->buildIndex();
 
@@ -129,7 +129,7 @@
                foreach( $qualifiersByProperty->getPropertyIds() as $propertyId 
) {
                        $snaklistviewsHtml .= $this->getSnaklistviewHtml(
                                $qualifiersByProperty->getByPropertyId( 
$propertyId ),
-                               $propertyInfo
+                               $entityInfo
                        );
                }
 
@@ -140,15 +140,15 @@
         * Generates the HTML for a ReferenceList object.
         *
         * @param ReferenceList $referenceList
-        * @param array[] $propertyInfo
+        * @param array[] $entityInfo
         *
         * @return string
         */
-       protected function getHtmlForReferences( ReferenceList $referenceList, 
array $propertyInfo ) {
+       protected function getHtmlForReferences( ReferenceList $referenceList, 
array $entityInfo ) {
                $referencesHtml = '';
 
                foreach( $referenceList as $reference ) {
-                       $referencesHtml .= $this->getHtmlForReference( 
$reference, $propertyInfo );
+                       $referencesHtml .= $this->getHtmlForReference( 
$reference, $entityInfo );
                }
 
                return $this->wrapInListview( $referencesHtml );
@@ -166,11 +166,11 @@
         * Generates the HTML for a Reference object.
         *
         * @param Reference $reference
-        * @param array[] $propertyInfo
+        * @param array[] $entityInfo
         *
         * @return string
         */
-       protected function getHtmlForReference( $reference, array $propertyInfo 
) {
+       protected function getHtmlForReference( $reference, array $entityInfo ) 
{
                $referenceSnaksByProperty = new ByPropertyIdArray( 
$reference->getSnaks() );
                $referenceSnaksByProperty->buildIndex();
 
@@ -179,7 +179,7 @@
                foreach( $referenceSnaksByProperty->getPropertyIds() as 
$propertyId ) {
                        $snaklistviewsHtml .= $this->getSnaklistviewHtml(
                                $referenceSnaksByProperty->getByPropertyId( 
$propertyId ),
-                               $propertyInfo
+                               $entityInfo
                        );
                }
 
@@ -193,16 +193,16 @@
         * Generates the HTML for a list of snaks.
         *
         * @param Snak[] $snaks
-        * @param array[] $propertyInfo
+        * @param array[] $entityInfo
         *
         * @return string
         */
-       protected function getSnaklistviewHtml( $snaks, array $propertyInfo ) {
+       protected function getSnaklistviewHtml( $snaks, array $entityInfo ) {
                $snaksHtml = '';
                $i = 0;
 
                foreach( $snaks as $snak ) {
-                       $snaksHtml .= $this->snakHtmlGenerator->getSnakHtml( 
$snak, $propertyInfo, ( $i++ === 0 ) );
+                       $snaksHtml .= $this->snakHtmlGenerator->getSnakHtml( 
$snak, $entityInfo, ( $i++ === 0 ) );
                }
 
                return wfTemplate(
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index 45acd67..faa84e1 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -535,7 +535,7 @@
                        $claimsByProperty[$propertyId->getNumericId()][] = 
$claim;
                }
 
-               $propertyInfo = $this->getPropertyInfo( $entity, 
$this->getLanguage()->getCode() );
+               $entityInfo = $this->getEntityInfo( $entity, 
$this->getLanguage()->getCode() );
 
                /**
                 * @var string $claimsHtml
@@ -549,9 +549,9 @@
                        $propertyId = 
$claims[0]->getMainSnak()->getPropertyId();
                        $key = $propertyId->getSerialization();
                        $propertyLabel = $key;
-                       if ( isset( $propertyInfo[$key] ) && !empty( 
$propertyInfo[$key]['labels'] ) ) {
-                               $propertyInfoLabel = reset( 
$propertyInfo[$key]['labels'] );
-                               $propertyLabel = $propertyInfoLabel['value'];
+                       if ( isset( $entityInfo[$key] ) && !empty( 
$entityInfo[$key]['labels'] ) ) {
+                               $entityInfoLabel = reset( 
$entityInfo[$key]['labels'] );
+                               $propertyLabel = $entityInfoLabel['value'];
                        }
 
                        $propertyLink = \Linker::link(
@@ -564,7 +564,7 @@
                        foreach( $claims as $claim ) {
                                $propertyHtml .= 
$this->claimHtmlGenerator->getHtmlForClaim(
                                        $claim,
-                                       $propertyInfo,
+                                       $entityInfo,
                                        $htmlForEditSection
                                );
                        }
@@ -644,15 +644,15 @@
        }
 
        /**
-        * Fetches labels for all properties used as properties in snaks in the 
given entity.
+        * Fetches labels and descriptions for all entities used as properties 
in snaks in the given
+        * entity.
         *
         * @param Entity $entity
         * @param string $languageCode the language code of the labels to fetch.
         *
-        * @todo: We may also want to have the descriptions, in addition to the 
labels
-        * @return array[] Property info array that maps property IDs to labels.
+        * @return array[] Entity info array that maps property IDs to labels 
and descriptions.
         */
-       protected function getPropertyInfo( Entity $entity, $languageCode ) {
+       protected function getEntityInfo( Entity $entity, $languageCode ) {
                wfProfileIn( __METHOD__ );
                // TODO: Share cache with PropertyLabelResolver
                // TODO: ... or share info with getBasicEntityInfo.
@@ -667,7 +667,11 @@
                // NOTE: This is a bit hackish, it would be more appropriate to 
use a TermTable here.
                $entityInfo = $this->entityInfoBuilder->buildEntityInfo( 
$propertyIds );
                $this->entityInfoBuilder->removeMissing( $entityInfo );
-               $this->entityInfoBuilder->addTerms( $entityInfo, array( 
'label', 'description' ), array( $languageCode ) );
+               $this->entityInfoBuilder->addTerms(
+                       $entityInfo,
+                       array( 'label', 'description' ),
+                       array( $languageCode )
+               );
 
                wfProfileOut( __METHOD__ );
                return $entityInfo;
diff --git a/repo/includes/view/SnakHtmlGenerator.php 
b/repo/includes/view/SnakHtmlGenerator.php
index edc75b2..6b03275 100644
--- a/repo/includes/view/SnakHtmlGenerator.php
+++ b/repo/includes/view/SnakHtmlGenerator.php
@@ -51,12 +51,12 @@
         * Generates the HTML for a single snak.
         *
         * @param Snak $snak
-        * @param array[] $propertyInfo
+        * @param array[] $entityInfo
         * @param bool $showPropertyLink
         *
         * @return string
         */
-       public function getSnakHtml( Snak $snak, array $propertyInfo, 
$showPropertyLink = false ) {
+       public function getSnakHtml( Snak $snak, array $entityInfo, 
$showPropertyLink = false ) {
                $snakViewVariation = $this->getSnakViewVariation( $snak );
                $snakViewCssClass = 'wb-snakview-variation-' . 
$snakViewVariation;
 
@@ -67,7 +67,7 @@
                }
 
                $propertyLink = $showPropertyLink ?
-                       $this->makePropertyLink( $snak, $propertyInfo, 
$showPropertyLink ) : '';
+                       $this->makePropertyLink( $snak, $entityInfo, 
$showPropertyLink ) : '';
 
                $html = wfTemplate( 'wb-snak',
                        // Display property link only once for snaks featuring 
the same property:
@@ -81,17 +81,17 @@
 
        /**
         * @param Snak $snak
-        * @param array[] $propertyInfo
+        * @param array[] $entityInfo
         *
         * @return string
         */
-       private function makePropertyLink( Snak $snak, array $propertyInfo ) {
+       private function makePropertyLink( Snak $snak, array $entityInfo ) {
                $propertyId = $snak->getPropertyId();
                $key = $propertyId->getSerialization();
                $propertyLabel = $key;
-               if ( isset( $propertyInfo[$key] ) && !empty( 
$propertyInfo[$key]['labels'] ) ) {
-                       $propertyInfoLabel = reset( 
$propertyInfo[$key]['labels'] );
-                       $propertyLabel = $propertyInfoLabel['value'];
+               if ( isset( $entityInfo[$key] ) && !empty( 
$entityInfo[$key]['labels'] ) ) {
+                       $entityInfoLabel = reset( $entityInfo[$key]['labels'] );
+                       $propertyLabel = $entityInfoLabel['value'];
                }
 
                // @todo use EntityIdHtmlLinkFormatter here
diff --git a/repo/tests/phpunit/includes/view/SnakHtmlGeneratorTest.php 
b/repo/tests/phpunit/includes/view/SnakHtmlGeneratorTest.php
index 8a4d90d..8e86d7a 100644
--- a/repo/tests/phpunit/includes/view/SnakHtmlGeneratorTest.php
+++ b/repo/tests/phpunit/includes/view/SnakHtmlGeneratorTest.php
@@ -28,7 +28,7 @@
        public function testGetSnakHtml(
                $snakFormatter,
                $entityTitleLookup,
-               $propertyInfo,
+               $entityInfo,
                $snak,
                $patterns
        ) {
@@ -37,7 +37,7 @@
                        $entityTitleLookup
                );
 
-               $html = $snakHtmlGenerator->getSnakHtml( $snak, $propertyInfo );
+               $html = $snakHtmlGenerator->getSnakHtml( $snak, $entityInfo );
 
                foreach( $patterns as $message => $pattern ) {
                        $this->assertRegExp( $pattern, $html, $message );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I46bdbd049521e10f8cb7a9bfbf13ad3ad96302f5
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to