'comment_count',
]);
foreach ($fields as $field_name =>
$detail) { // Skip fields that entity does not have.
if (!
$entity->
hasField($field_name)) { continue;
} // Get the user ID from the entity if it's set, or default to the
// currently logged in user.
$last_comment_uid = 0;
if ($entity instanceof EntityOwnerInterface
) { $last_comment_uid =
$entity->
getOwnerId();
} 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
) {