Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: Drop static EntityView::typeMap
......................................................................

Drop static EntityView::typeMap

I can't find any usage of this. Please double check.

Change-Id: I645493cd642b75a01b0ecd8d6d6ab583dd15204e
---
M repo/includes/EntityView.php
1 file changed, 11 insertions(+), 30 deletions(-)


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

diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index 1a6738e..1e204d3 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -6,8 +6,6 @@
 use InvalidArgumentException;
 use Language;
 use Wikibase\DataModel\Entity\Entity;
-use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
 use Wikibase\Repo\View\ClaimsView;
 use Wikibase\Repo\View\FingerprintView;
 use Wikibase\Repo\View\TextInjector;
@@ -49,22 +47,6 @@
         */
        protected $textInjector;
 
-       /**
-        * Maps entity types to the corresponding entity view.
-        * FIXME: remove this stuff, big OCP violation
-        *
-        * @since 0.2
-        *
-        * @var string[]
-        */
-       public static $typeMap = array(
-               Item::ENTITY_TYPE => '\Wikibase\ItemView',
-               Property::ENTITY_TYPE => '\Wikibase\PropertyView',
-
-               // TODO: Query::ENTITY_TYPE
-               'query' => '\Wikibase\QueryView',
-       );
-
        public function __construct(
                FingerprintView $fingerprintView,
                ClaimsView $claimsView,
@@ -74,6 +56,7 @@
                $this->fingerprintView = $fingerprintView;
                $this->claimsView = $claimsView;
                $this->language = $language;
+
                $this->textInjector = new TextInjector();
        }
 
@@ -99,6 +82,7 @@
         *
         * @param EntityRevision $entityRevision the entity to render
         * @param bool $editable whether editing is allowed (enabled edit links)
+        *
         * @return string HTML
         */
        public function getHtml( EntityRevision $entityRevision, $editable = 
true ) {
@@ -107,9 +91,8 @@
                //NOTE: even though $editable is unused at the moment, we will 
need it for the JS-less editing model.
 
                $entityId = $entity->getId() ?: 'new'; // if id is not set, use 
'new' suffix for css classes
-               $html = '';
 
-               $html .= wfTemplate( 'wikibase-entityview',
+               $html = wfTemplate( 'wikibase-entityview',
                        $entity->getType(),
                        $entityId,
                        $this->language->getCode(),
@@ -165,8 +148,7 @@
 
                $entity = $entityRevision->getEntity();
 
-               $html = '';
-               $html .= $this->getHtmlForFingerprint( $entity, $editable );
+               $html = $this->getHtmlForFingerprint( $entity, $editable );
                $html .= $this->getHtmlForToc();
                $html .= $this->getHtmlForTermBox( $entityRevision, $editable );
 
@@ -179,6 +161,7 @@
         *
         * @param Entity $entity
         * @param bool $editable
+        *
         * @return string
         */
        protected function getHtmlForFingerprint( Entity $entity, $editable = 
true ) {
@@ -191,7 +174,6 @@
         * @return string
         */
        protected function getHtmlForToc() {
-               $tocContent = '';
                $tocSections = $this->getTocSections();
 
                if ( count( $tocSections ) < 2 ) {
@@ -203,7 +185,7 @@
 
                // Placeholder for the TOC entry for the term box (which may or 
may not be used for a given user).
                // EntityViewPlaceholderExpander must know about the 
'termbox-toc' name.
-               $tocContent .= $this->textInjector->newMarker( 'termbox-toc' );
+               $tocContent = $this->textInjector->newMarker( 'termbox-toc' );
 
                $i = 1;
 
@@ -215,12 +197,10 @@
                        );
                }
 
-               $toc = wfTemplate( 'wb-entity-toc',
+               return wfTemplate( 'wb-entity-toc',
                        wfMessage( 'toc' )->text(),
                        $tocContent
                );
-
-               return $toc;
        }
 
        /**
@@ -234,17 +214,18 @@
 
        /**
         * @param EntityRevision $entityRevision
-        * @param bool $editable
         *
         * @return string
         */
        protected function getHtmlForTermBox( EntityRevision $entityRevision ) {
-               if ( $entityRevision->getEntity()->getId() ) {
+               $entityId = $entityRevision->getEntity()->getId();
+
+               if ( $entityId !== null ) {
                        // Placeholder for a termbox for the present item.
                        // EntityViewPlaceholderExpander must know about the 
parameters used here.
                        return $this->textInjector->newMarker(
                                'termbox',
-                               
$entityRevision->getEntity()->getId()->getSerialization(),
+                               $entityId->getSerialization(),
                                $entityRevision->getRevision()
                        );
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I645493cd642b75a01b0ecd8d6d6ab583dd15204e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to