This is my first foray into Drupal 8 and I am being stumped.
I am trying to get the filename of a file in a file field (and its location on disk if possible) after a node has been updated. Right now I am implementing hook_entity_update and am sometimes getting unexpected entity id with the following code:
function mymodule_entity_update(Drupal\Core\Entity\EntityInterface $entity)
{
die($entity->id());
}
If I update the node and change other fields besides the file field, it prints the node's entity id.
If I update the node and delete/replace the file in the file field, it prints the file's entity id.
I expect it to always print the node's entity id, so I am obviously not understanding something here.
The end game is to copy the file in the file field to a specific location after the node has been updated, but I am having trouble reliably getting the values I expect. If anybody can help me understand what is happening I'd appreciate it.