Put hooks_views_data() in a separated file .views.inc

Created on 24 May 2025, 3 months ago

Is recommended to put hooks_views_data() in a separated file .views.inc

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇪🇸Spain daniels____

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @daniels____
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    There is no requirement to put hook_views_data() in a .views.inc file. When there is no .views.inc file, the hook is looked for in the .module file.

    If there were a requirement, Drupal core would at least log a warning, or a deprecation error.

  • 🇦🇹Austria agoradesign Grieskirchen

    daniels____ wrote, that it is recommended, not required.

    Although this is or at least was true in former days, I'm against changing this for a simple reason. This change would be an unnecessary and unsustainable step. Drupal 11.2 introduced a lot of OOP hooks, deprecating many of the procedural hooks, we are all used for years. I honestly don't know exactly, whether hook_views_data() does already have an OOP replacement too, but in the long run any hook will be replaced, I guess (comparable with the fact, that any plugin declaration is currently going to be changed from annotations to PHP attributes)

Production build 0.71.5 2024