Entity revisions

In Drupal 8, all content entity types can be made revisionable (and publishable) with minimal effort. Since Node is such an example, we can check out how it's built to understand this better.

First, the annotation needs to have the database table information where revisions are stored. This mirrors exactly the original tables we saw before:

revision_table = "node_revision",revision_data_table = "node_field_revision",

Second, the annotation needs to have the entity keys for the revision ID and the published status we saw earlier:

*   entity_keys = { 
*     "revision" = "vid", 
*     "published" = "status", 
*   }, 

Third, also in the annotation, the revision metadata keys need to be referenced:

* revision_metadata_keys = { * "revision_user" ...

Get Drupal 8 Module Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.