Compile a list of all dirty fields in an entity?


When I debug($entity) after doing a patchEntity, I can see a list of dirty fields. Outside of debug(), I can’t seem to acces these values in any way I can figure out.

I would like to be able to keep a list of fields that were modified and the original values and new values to save to a modification history table.

I tried using $entity->dirty() but that just yields “true” or “false”… and then $entity->getOriginal() needs an argument (just one specific field I’m after).

Surely there is a way to access the list of fields and values without knowing ahead of time which ones (if any) they might be, no?


I don’t think there is a way to access $_dirty since $_dirty is a protected property without a public function to access it.