Allow @FieldType to customize views data

Created on 12 September 2014, about 10 years ago
Updated 22 March 2023, over 1 year ago

Problem/Motivation

Views integration works for config fields created in the UI, but not for base fields added to the entity types in code.

As an example, consider Date module. That diligently implements datetime_range_field_views_data() to declare its custom Views filters and arguments. But if I add a date field to my entity's base fields, the Views integration is completely missing.

Proposed resolution

Add the views handler to the field annotation as with the entity annotation. Provide the default base class for standard views data. Allow custom fields to have specific classes for views data.

Remaining tasks

Write a patch for the above proposed resolution.

User interface changes

None

API changes

API completion

Data model changes

None

Release notes snippet

TBC

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated about 2 hours ago

Created by

πŸ‡©πŸ‡ͺGermany dawehner

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Merge request !36982337515 on 9.5.x β†’ (Open) created by joachim
  • πŸ‡¬πŸ‡§United Kingdom joachim

    Rebased branches, and made a new MR for 9.5.x.

    Not had time to consider the architectural questions raised by Berdir :(

    I wonder if plugin decoration would be a way to do this: #2958184: Allow decoration of plugins β†’ .

    Or we just specify a handler class name?

  • First commit to issue fork.
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    Amazing! Hiding patches iFo the MR.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    I've just realised this is closely linked to hook_field_views_data_views_data_alter()

    The docs for that say:

    > The Views module's implementation of hook_views_data_alter() invokes this for each field storage, in the module that defines the field type. It is not invoked in other modules.

    So it's basically: the module defining the field type gets to say something about Views data. That hook is still needed, because it allows field type providers to do things like reverse entity references.

    But as a follow-up we could move that hook to the new handler classes that this issue will introduce.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    I'm removing commit e7790601 because it's making lots of unrelated changes, which is making the branch harder to rebase.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    Rebased to 11.x and made a new branch.

  • Merge request !98402337515 β†’ (Open) created by joachim
  • Pipeline finished with Failed
    about 2 months ago
    Total: 147s
    #310316
  • Pipeline finished with Failed
    about 2 months ago
    #310721
Production build 0.71.5 2024