EntityViewsData::getViewsTableForEntityType() does the job of figuring out the database table that Views should use for a given entity type.

It's currently protected, but other modules need this logic too, when adding fields to views data in hook_views_data_alter().

For example, Flag module needs to add a relationship from entity types that have flags on them to the flagging entity. For this, it needs to know which base table Views uses for each entity type.

Comments

joachim’s picture

Status: Active » Needs review
StatusFileSize
new1.5 KB

Status: Needs review » Needs work

The last submitted patch, 1: 2491687.drupal.getViewsTableForEntityType-public.patch, failed testing.

joachim’s picture

Status: Needs work » Needs review
StatusFileSize
new1.66 KB
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Seems sane

jibran’s picture

Title: make EntityViewsData::getViewsTableForEntityType() public rather than protected » Make EntityViewsData::getViewsTableForEntityType() public rather than protected
Category: Feature request » Task
Priority: Normal » Major

Flag is widely used module including d.o. Having proper views support for it should be considered major task.

xjm’s picture

Priority: Major » Normal
Status: Reviewed & tested by the community » Fixed

@jibran, I don't think it's major, because the workaround is just to duplicate the one line of code where needed. However, agreed with task.

A part of my brain wanted to ask for a unit test for this since it's public now, but the other part of my brain said the method is trivial enough that meh. If someone else would like to file a followup to add test coverage, cool.

This is also missing a beta evaluation (really all non-critical tasks should always have one), but I think changes that make contrib code more reliable can also be prioritized, and it's not like there's any disruption. Going forward, though, please be sure to add beta evaluations to tasks during this phase of the release cycle.

Committed and pushed to 8.0.x. Thanks!

  • xjm committed 68fdeaf on 8.0.x
    Issue #2491687 by joachim: Make EntityViewsData::...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.