/** * Finds the field name for the field carrying the changed timestamp, if any. * * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity. * * @return string|null * The name of the field found or NULL if not found. */ protected function getChangedFieldName(FieldableEntityInterface $entity) { foreach ($entity->getFieldDefinitions() as $field) { if ($field->getType() == 'changed') { return $field->getName(); } } }