Adrian Heine has uploaded a new change for review.

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

Change subject: WIP
......................................................................

WIP

Change-Id: Id821e4525de4380f9933d429d90751e0954bc0f5
---
M repo/WikibaseRepo.entitytypes.php
M repo/includes/ParserOutput/DispatchingEntityViewFactory.php
M repo/includes/ParserOutput/EntityParserOutputGenerator.php
M repo/tests/phpunit/includes/EntityTypesTest.php
M repo/tests/phpunit/includes/ParserOutput/DispatchingEntityViewFactoryTest.php
5 files changed, 24 insertions(+), 53 deletions(-)


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

diff --git a/repo/WikibaseRepo.entitytypes.php 
b/repo/WikibaseRepo.entitytypes.php
index 1fbe0d2..c739fa6 100644
--- a/repo/WikibaseRepo.entitytypes.php
+++ b/repo/WikibaseRepo.entitytypes.php
@@ -22,7 +22,6 @@
 use Wikibase\LanguageFallbackChain;
 use Wikibase\Repo\WikibaseRepo;
 use Wikibase\View\EditSectionGenerator;
-use Wikibase\View\EntityTermsView;
 
 return array(
        'item' => array(
@@ -30,16 +29,14 @@
                        $languageCode,
                        LabelDescriptionLookup $labelDescriptionLookup,
                        LanguageFallbackChain $fallbackChain,
-                       EditSectionGenerator $editSectionGenerator,
-                       EntityTermsView $entityTermsView
+                       EditSectionGenerator $editSectionGenerator
                ) {
                        $viewFactory = 
WikibaseRepo::getDefaultInstance()->getViewFactory();
                        return $viewFactory->newItemView(
                                $languageCode,
                                $labelDescriptionLookup,
                                $fallbackChain,
-                               $editSectionGenerator,
-                               $entityTermsView
+                               $editSectionGenerator
                        );
                },
                'content-model-id' => CONTENT_MODEL_WIKIBASE_ITEM,
@@ -57,15 +54,13 @@
                        LabelDescriptionLookup $labelDescriptionLookup,
                        LanguageFallbackChain $fallbackChain,
                        EditSectionGenerator $editSectionGenerator,
-                       EntityTermsView $entityTermsView
                ) {
                        $viewFactory = 
WikibaseRepo::getDefaultInstance()->getViewFactory();
                        return $viewFactory->newPropertyView(
                                $languageCode,
                                $labelDescriptionLookup,
                                $fallbackChain,
-                               $editSectionGenerator,
-                               $entityTermsView
+                               $editSectionGenerator
                        );
                },
                'content-model-id' => CONTENT_MODEL_WIKIBASE_PROPERTY,
diff --git a/repo/includes/ParserOutput/DispatchingEntityViewFactory.php 
b/repo/includes/ParserOutput/DispatchingEntityViewFactory.php
index 2c40517..8b654dc 100644
--- a/repo/includes/ParserOutput/DispatchingEntityViewFactory.php
+++ b/repo/includes/ParserOutput/DispatchingEntityViewFactory.php
@@ -7,7 +7,6 @@
 use Wikibase\LanguageFallbackChain;
 use Wikibase\View\EditSectionGenerator;
 use Wikibase\View\EntityView;
-use Wikibase\View\EntityTermsView;
 use Wikimedia\Assert\Assert;
 
 /**
@@ -42,7 +41,6 @@
         * @param LabelDescriptionLookup $labelDescriptionLookup
         * @param LanguageFallbackChain $languageFallbackChain
         * @param EditSectionGenerator $editSectionGenerator
-        * @param EntityTermsView $entityTermsView
         *
         * @throws OutOfBoundsException
         * @return EntityView
@@ -52,8 +50,7 @@
                $languageCode,
                LabelDescriptionLookup $labelDescriptionLookup,
                LanguageFallbackChain $languageFallbackChain,
-               EditSectionGenerator $editSectionGenerator,
-               EntityTermsView $entityTermsView
+               EditSectionGenerator $editSectionGenerator
        ) {
                if ( !isset( $this->entityViewFactoryCallbacks[$entityType] ) ) 
{
                        throw new OutOfBoundsException( "No EntityView is 
registered for entity type '$entityType'" );
@@ -64,8 +61,7 @@
                        $languageCode,
                        $labelDescriptionLookup,
                        $languageFallbackChain,
-                       $editSectionGenerator,
-                       $entityTermsView
+                       $editSectionGenerator
                );
 
                Assert::postcondition(
diff --git a/repo/includes/ParserOutput/EntityParserOutputGenerator.php 
b/repo/includes/ParserOutput/EntityParserOutputGenerator.php
index 0944154..cc039c4 100644
--- a/repo/includes/ParserOutput/EntityParserOutputGenerator.php
+++ b/repo/includes/ParserOutput/EntityParserOutputGenerator.php
@@ -283,36 +283,29 @@
                        $this->textProvider
                ) : new EmptyEditSectionGenerator();
 
-               $languageDirectionalityLookup = new 
MediaWikiLanguageDirectionalityLookup();
-               $languageNameLookup = new LanguageNameLookup( 
$this->languageCode );
-               $termsListView = new TermsListView(
-                       TemplateFactory::getDefaultInstance(),
-                       $languageNameLookup,
-                       new MediaWikiLocalizedTextProvider( $this->languageCode 
),
-                       $languageDirectionalityLookup
-               );
-
                $textInjector = new TextInjector();
-               $entityTermsView = new PlaceholderEmittingEntityTermsView(
-                       new FallbackHintHtmlTermRenderer(
-                               $languageDirectionalityLookup,
-                               $languageNameLookup
-                       ),
-                       $labelDescriptionLookup,
-                       $this->templateFactory,
-                       $editSectionGenerator,
-                       $this->textProvider,
-                       $termsListView,
-                       $textInjector
-               );
+
+               /**
+                * TextInjector needs to be created here
+                * WBRepo/DispatchingEntityViewFactory should not know about it
+                * EntityType::view-factory-callback should not know about it
+                * WBView/ViewFactory must not know about it
+                * TextInjector is used in PlaceholderEmittingEntityTermsView
+
+                * Make DispatchingEntityViewFactory extend ViewFactory
+                * Add ViewFactory::newEntityTermsView
+                * Make DispatchingEntityViewFactory::newEntityTermsView return 
a PlaceholderEmittingEntityTermsView
+                * Make DispatchingEntityViewFactory::newEntityView take a 
textInjector
+                * Make it pass $this to the builder functions
+                * Let the builders use $this->newEntityTermsView
+                */
 
                $entityView = $this->entityViewFactory->newEntityView(
                        $entity->getType(),
                        $this->languageCode,
                        $labelDescriptionLookup,
                        $this->languageFallbackChain,
-                       $editSectionGenerator,
-                       $entityTermsView
+                       $editSectionGenerator
                );
 
                // Set the display title to display the label together with the 
item's id
diff --git a/repo/tests/phpunit/includes/EntityTypesTest.php 
b/repo/tests/phpunit/includes/EntityTypesTest.php
index 855f1f1..62257ea 100644
--- a/repo/tests/phpunit/includes/EntityTypesTest.php
+++ b/repo/tests/phpunit/includes/EntityTypesTest.php
@@ -7,7 +7,6 @@
 use Wikibase\LanguageFallbackChain;
 use Wikibase\Repo\Content\EntityHandler;
 use Wikibase\View\EditSectionGenerator;
-use Wikibase\View\EntityTermsView;
 use Wikibase\View\EntityView;
 
 /**
@@ -51,15 +50,12 @@
 
                $this->assertInternalType( 'callable', $callback );
 
-               $entityTermsView = $this->getMock( EntityTermsView::class );
-
                $entityView = call_user_func(
                        $callback,
                        'en',
                        $this->getMock( LabelDescriptionLookup::class ),
                        new LanguageFallbackChain( [] ),
-                       $this->getMock( EditSectionGenerator::class ),
-                       $entityTermsView
+                       $this->getMock( EditSectionGenerator::class )
                );
 
                $this->assertInstanceOf( EntityView::class, $entityView );
diff --git 
a/repo/tests/phpunit/includes/ParserOutput/DispatchingEntityViewFactoryTest.php 
b/repo/tests/phpunit/includes/ParserOutput/DispatchingEntityViewFactoryTest.php
index cd81a3f..e05f29d 100644
--- 
a/repo/tests/phpunit/includes/ParserOutput/DispatchingEntityViewFactoryTest.php
+++ 
b/repo/tests/phpunit/includes/ParserOutput/DispatchingEntityViewFactoryTest.php
@@ -10,7 +10,6 @@
 use Wikibase\LanguageFallbackChain;
 use Wikibase\Repo\ParserOutput\DispatchingEntityViewFactory;
 use Wikibase\View\EditSectionGenerator;
-use Wikibase\View\EntityTermsView;
 use Wikibase\View\EntityView;
 
 /**
@@ -37,15 +36,13 @@
                $factory = new DispatchingEntityViewFactory(
                        array()
                );
-               $entityTermsView = $this->getMock( EntityTermsView::class );
 
                $factory->newEntityView(
                        'unknown',
                        'en',
                        $this->getMock( LabelDescriptionLookup::class ),
                        new LanguageFallbackChain( array() ),
-                       $this->getMock( EditSectionGenerator::class ),
-                       $entityTermsView
+                       $this->getMock( EditSectionGenerator::class )
                );
        }
 
@@ -60,15 +57,13 @@
                                }
                        )
                );
-               $entityTermsView = $this->getMock( EntityTermsView::class );
 
                $factory->newEntityView(
                        'foo',
                        'en',
                        $this->getMock( LabelDescriptionLookup::class ),
                        new LanguageFallbackChain( array() ),
-                       $this->getMock( EditSectionGenerator::class ),
-                       $entityTermsView
+                       $this->getMock( EditSectionGenerator::class )
                );
        }
 
@@ -76,7 +71,6 @@
                $labelDescriptionLookup = $this->getMock( 
LabelDescriptionLookup::class );
                $languageFallbackChain = new LanguageFallbackChain( array() );
                $editSectionGenerator = $this->getMock( 
EditSectionGenerator::class );
-               $entityTermsView = $this->getMock( EntityTermsView::class );
                $entityView = $this->getMockBuilder( EntityView::class )
                        ->disableOriginalConstructor()
                        ->getMockForAbstractClass();
@@ -88,19 +82,16 @@
                                        LabelDescriptionLookup 
$labelDescriptionLookupParam,
                                        LanguageFallbackChain 
$languageFallbackChainParam,
                                        EditSectionGenerator 
$editSectionGeneratorParam,
-                                       EntityTermsView $entityTermsViewParam
                                ) use(
                                        $labelDescriptionLookup,
                                        $languageFallbackChain,
                                        $editSectionGenerator,
-                                       $entityTermsView,
                                        $entityView
                                ) {
                                        $this->assertEquals( 'en', 
$languageCodeParam );
                                        $this->assertSame( 
$labelDescriptionLookup, $labelDescriptionLookupParam );
                                        $this->assertSame( 
$languageFallbackChain, $languageFallbackChainParam );
                                        $this->assertSame( 
$editSectionGenerator, $editSectionGeneratorParam );
-                                       $this->assertSame( $entityTermsView, 
$entityTermsViewParam );
 
                                        return $entityView;
                                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id821e4525de4380f9933d429d90751e0954bc0f5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Heine <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