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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.