if (!
isset($last_comment_uid)) { // Default to current user when entity does not implement
// EntityOwnerInterface or author is not set.
$last_comment_uid =
$this->currentUser->
id();
} // Default to REQUEST_TIME when entity does not have a changed property.
$last_comment_timestamp = REQUEST_TIME;
// @todo Make comment statistics language aware and add some tests. See
// https://www.drupal.org/node/2318875
if ($entity instanceof EntityChangedInterface
) { $last_comment_timestamp =
$entity->
getChangedTimeAcrossTranslations();
} $query->
values([ 'entity_id' =>
$entity->
id(),
'entity_type' =>
$entity->
getEntityTypeId(),
'field_name' =>
$field_name,
'cid' => 0,
'last_comment_timestamp' =>
$last_comment_timestamp,
'last_comment_name' => NULL,
'last_comment_uid' =>
$last_comment_uid,
'comment_count' => 0,
]);
}