protected function UserStatistics::count in Open Social 10.3.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()
- 8.8 modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()
- 10.0.x modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()
- 10.1.x modules/social_features/social_profile/src/UserStatistics.php \Drupal\social_profile\UserStatistics::count()
- 10.2.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_profileCode
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();
}