7. Tracking changes to entities
Drupal provides a mechanism to track changes of entities by storing a new revision of an entity each time it is saved.
7.1. Make events revisionable
Section titled “7.1. Make events revisionable”-
Add the following use statements to
src/Entity/Event.php: -
Add the following to the
entity_keysof theEventclass attributes: -
Add the following to the attributes of the
Eventclass: -
Add
, RevisionLogEntityTraitto theusepart inside of theEventclass -
Add the following before the
returnstatement of thebaseFieldDefinitions()method of theEventclass: -
Run
drush entity:updates -
Verify that the
event_revisiontable was created -
Verify that the Revision information vertical tab appears on the event edit form
7.2. Add a user interface for managing revisions
Section titled “7.2. Add a user interface for managing revisions”-
Add the following use statements to
src/Entity/Event.php: -
Add the following to the
route_providerentry of thehandlerssection of the attributes of theEventclass: -
Add the following to the
linkssection of the annotation of theEventclass: