You are here

protected function UserStatistics::count in Open Social 10.2.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()
  2. 8.8 modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()
  3. 10.3.x modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()
  4. 10.0.x modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()
  5. 10.1.x modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()

Get entity count by type for the profile.

Parameters

int $user_id: The user ID.

string $type: Entity type.

Return value

int The number of entities.

1 call to UserStatistics::count()
UserStatistics::nodeCount in modules/social_features/social_profile/src/UserStatistics.php
Get node count by type.

File

modules/social_features/social_profile/src/UserStatistics.php, line 57

Class

UserStatistics
Class UserStatistics.

Namespace

Drupal\social_profile

Code

protected function count($user_id, $type) {
  $query = $this->database
    ->select('node_field_data', 'nfd');
  $query
    ->addField('nfd', 'nid');
  $query
    ->condition('nfd.uid', $user_id);
  $query
    ->condition('nfd.type', $type, 'LIKE');
  return $query
    ->countQuery()
    ->execute()
    ->fetchField();
}