Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This behavior can be modified using the model variable $relinkToArchive. If a Model defines a related hasOne or hasMany Model in this variable, then ChangelogBehavior will relink the related model to the archive copy, as part of the afterSave callback. This is useful for maintaining historical context, such as for Petition attribute definitions. If the Model relationship is belongsTo, a similar rewrite happens, but in beforeSave and with the assumption that the parent model is what was changed. (The belongsTo relationship is used for when related Models are saved simultaneously as part of a saveAll or saveAssociated call.)

See also: Understanding Registry Deletion

Enabling Changelogs for a Model

...

$relinkToArchive should also be defined if needed, as described above.

When a hard delete must be performed, ChangelogBehavior can be initialized with the setting expunge set to true. This setting is also supported by StandardController, via the controller level setting $useHardDelete.

Info

actor_identifier stores the username (identifier) of whoever made the change. This is a string rather than a foreign key into cm_co_people for several reasons:

  • No need for foreign keys and Model relations, which must be added to each Changelog model, and are tricky to automatically create for tables created in schema.xml before cm_co_people.
  • Audit integrity is maintained even after an expunge.
  • Some models are not attached to a CO, so tracking a CO Person as an actor doesn't quite make sense.

 

...

Delete

  • deleted is set to true (effecting a soft delete), unless ChangelogBehavior is initialized with the setting expunge set to true (in which case a hard delete is performed).

Find

  • By default, a find that does not request a specific record ID will be modified to return the most current revision and to exclude deleted records.
  • A find with the parameter archived set to true will return all records, not just those described above.
  • If ChangelogBehavior is initialized with the setting expunge set to true, all records will be returned, not just those described above.

...