Page MenuHomePhabricator

[Task] Allow extensions to register additonal EntityViews
Closed, ResolvedPublic

Description

Extensions should be able to register their own Views to display other types of entity. This requires a common interface on the one hand and an extension mechanism plus a factor on the other hand.

Related Objects

StatusAssignedTask
Declineddchen
OpenNone
OpenNone
DuplicateNone
OpenNone
ResolvedAbit
DuplicateNone
OpenNone
OpenNone
OpenNone
OpenNone
DuplicateNone
InvalidNone
InvalidNone
InvalidLydia_Pintscher
Resolveddaniel
ResolvedTobi_WMDE_SW
Resolvedadrianheine
Resolvedadrianheine
OpenNone
OpenNone
StalledNone
OpenNone
OpenNone
Resolvedthiemowmde
OpenNone
Resolveddaniel
ResolvedBene

Event Timeline

Bene created this task.Feb 17 2016, 3:55 PM
Bene claimed this task.
Bene raised the priority of this task from to Needs Triage.
Bene updated the task description. (Show Details)
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald TranscriptFeb 17 2016, 3:55 PM

Change 271345 had a related patch set uploaded (by Bene):
Allow injection of entity views

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

adrianheine added a subscriber: adrianheine.EditedFeb 18 2016, 3:19 PM

From my point of view, WikibaseView is a component providing widgets for a specific set of WikibaseDataModel concepts. Since the widgets for items and properties use all other widgets, we provide an EntityViewFactory wiring them together. Wikibase\View\EntityViewFactory could look like the following for all I (aka WikibaseView) care about:

EntityViewFactory
  __construct()
  newItemView( ...allTheServicesAndValues ): ItemView
  newPropertyView( ...allTheServicesAndValues ): PropertyView

Also, WikibaseView should define an EntityView interface:

EntityView
  getTitleHtml( Entity ): HtmlString
  getHtml( Entity ): HtmlString
  getPlaceholders(): mixed[]

With that, WikibaseView seems done to me.

WikibaseRepo (namely EntityParserOutputGenerator) on the other hand needs something where it can just put in an entity type and a few other things and get a view. That factory thing should be defined in WikibaseRepo, instantiated in WikibaseRepo.php based on config, and passed to EntityParserOutputGenerator. It would use Wikibase\View\EntityViewFactory.

Lydia_Pintscher triaged this task as Normal priority.Feb 19 2016, 9:56 AM
Lydia_Pintscher added a subscriber: Bene.
Bene added a comment.Feb 23 2016, 10:31 AM

From my point of view, WikibaseView is a component providing widgets for a specific set of WikibaseDataModel concepts. Since the widgets for items and properties use all other widgets, we provide an EntityViewFactory wiring them together. Wikibase\View\EntityViewFactory could look like the following for all I (aka WikibaseView) care about:

EntityViewFactory
  __construct()
  newItemView( ...allTheServicesAndValues ): ItemView
  newPropertyView( ...allTheServicesAndValues ): PropertyView

I'd also add factory methods for the StatementSectionsView and EntityTermsView because extensions of Wikibase defining new entity types want to reuse those views.

Also, WikibaseView should define an EntityView interface:

EntityView
  getTitleHtml( Entity ): HtmlString
  getHtml( Entity ): HtmlString
  getPlaceholders(): mixed[]

This is almost what EntityView currently does. We can however refactor this and define a new public interface of EntityView which doesn't contain the protected abstract functions for main and side HTML.

With that, WikibaseView seems done to me.
WikibaseRepo (namely EntityParserOutputGenerator) on the other hand needs something where it can just put in an entity type and a few other things and get a view. That factory thing should be defined in WikibaseRepo, instantiated in WikibaseRepo.php based on config, and passed to EntityParserOutputGenerator. It would use Wikibase\View\EntityViewFactory.

I agree on that.

I'd also add factory methods for the StatementSectionsView and EntityTermsView because extensions of Wikibase defining new entity types want to reuse those views.

Why is a factory method necessary for them? They can just be instantiated in the factory method creating the view.

Bene added a comment.Feb 23 2016, 1:31 PM

@adrianheine mainly because they need access to the TemplateFactory which isn't available outside of Wikibase.

But TemplateFactory is constructed in WikibaseRepo via TemplateFactory::getDefaultInstance() and then injected into EntityViewFactory. The same could be done for a MediaInfoViewFactory.

Bene added a comment.Mar 2 2016, 11:17 AM

TemplateFactory doesn't seem to serve a purpose here because we cannot inject other templates from another component/extension. It might be nice to make that class modular to be able to support other template files as well but for now it isn't useful for any other extensions.

TemplateFactory doesn't seem to serve a purpose here because we cannot inject other templates from another component/extension. It might be nice to make that class modular to be able to support other template files as well but for now it isn't useful for any other extensions.

Sure, but what does that have to do with the point here?

Change 271345 merged by jenkins-bot:
Move entity type dispatching out of WikibaseView

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

Change 274393 had a related patch set uploaded (by Bene):
Dispatch entity views based on callbacks

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

Change 274393 merged by jenkins-bot:
Dispatch entity views based on callbacks

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

Change 274731 had a related patch set uploaded (by Bene):
Add view-factory-callback to the entity type definitions

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

Bene moved this task from Doing to Review on the Wikidata-Sprint-2016-03-01 board.Mar 3 2016, 3:47 PM
daniel added a subscriber: daniel.Mar 3 2016, 4:51 PM
This comment was removed by daniel.

Change 274731 merged by jenkins-bot:
Add view-factory-callback to the entity type definitions

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

Bene closed this task as Resolved.Mar 8 2016, 7:19 PM
Bene moved this task from Review to Done on the Wikidata-Sprint-2016-03-01 board.