The problem

We have a number of subsystems or contributed modules that rely on metadata for entities or similar data structures, such as Views, Token, Ctools exportables, DB backends and of course the entity system itself. A couple of examples of metadata hooks:
- hook_schema()
- hook_views_data()
- hook_token_info()
- hook_entity_info()
- hook_entity_property_info()

To me, this looks like missing one bird with a hundred stones. To me, this looks like we have to look if
we can do this with a single metadata hook.

A possible solution

This hook would do what the hooks mentioned above do as well: provide descriptive information about data within a 'structure', both variable-level (variable type, allowed values, max length, min/max int value) and content-level (what does the value represent?, title, description, date, reference to a variable in another data structure). It would by default NOT provide usage-specific data, such whether a data structure is available for querying by Views, or the DB layer should create tables for it.

However, 'users' of such a hook (Views, Token, etc) can require their own extra metadata if integration is needed. Views would perhaps need a flag that indicates whether the data can be queried. The DB system may need a flag that says a table needs to be created automatically for a certain data structure. Ctools may require custom metadata that describes how the data structure should be exported. And so on, and so on.

Data structures do not necessarily have to be entities, nor do they have to be available to Views. The hook itself would only describe the data in a general way. Specific users of the hook (Views, Token, DB layer) can however require extra metadata for integration.

Building the solution

Once we designed the new hook, we'd need to convert hook_schema(), hook_entity_info() and hook_token_info() one at a time. There would be no architectural changes involved. The metadata will not or hardly change. It's mostly the location of this data that will be different.

Advantages

- Less code, since metadata doesn't have to be kept up to date in different places.
- Integration with other modules requires less work, because only a few missing pieces will have to be added to the new hook, rather than implementing another specific hook.

Comments

sun’s picture

Issue tags:+Entity system
fago’s picture

Xano’s picture

Status:Active» Closed (won't fix)
Xano’s picture

Issue summary:View changes

Clarified this is not just about entities.