I have a custom revisionable entity with a few dozen fields. I'm importing data about the entity on a periodic basis. If the entity has changed, I'd like to save it and create a new revision.
$dogs = \Drupal::entityTypeManager()
->getStorage('my_entity')
->loadByProperties(['my_entity_id' => $my_entity_id]);
$dog = reset($dogs);
$dog->set('name', $record['TheName']);
$dog->set('birth_date', $record['Dog Birth Date']);
// Lots more ->set happening here.
$dog->set('notes', $record['Notes']);
if ($dog->someMagicComparisonFunction()) {
$dog->setNewRevision(TRUE);
$dog->save();
}
I searched for the someMagicComparisonFunction
but didn't find it. Does it exist?