function social_user_export_nodes_count in Open Social 8
Same name and namespace in other branches
- 8.2 modules/social_features/social_user_export/social_user_export.module \social_user_export_nodes_count()
Returns quantity of nodes created by specific user.
Parameters
\Drupal\user\UserInterface $account: The account to get the data for.
string $type: The node type to filter on.
Return value
int Quantity of nodes created by the account.
1 call to social_user_export_nodes_count()
- ExportUser::exportUserOperation in modules/
social_features/ social_user_export/ src/ ExportUser.php - Callback of one operation.
File
- modules/
social_features/ social_user_export/ social_user_export.module, line 139 - The Social User Export module.
Code
function social_user_export_nodes_count(UserInterface $account, $type) {
$query = \Drupal::database()
->select('node', 'n');
$query
->join('node_field_data', 'nfd', 'nfd.nid = n.nid');
$query
->condition('nfd.type', $type)
->condition('nfd.uid', $account
->id());
return (int) $query
->countQuery()
->execute()
->fetchField();
}