RVRNEXT-43 extend community member repository with count

This commit is contained in:
Bence Pőcze 2023-06-17 13:17:29 +02:00
parent eebf4aff00
commit 4e9c7f8c3c
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D

View File

@ -15,12 +15,16 @@ class CommunityMemberRepository
public function getAllByCommunity(Community $community, bool $useRelations = false, array $withRelations = []): Generator
{
$select = new Select(\Container::$dbConnection);
$select->where('community_id', '=', $community->getId());
$select = $this->selectAllByCommunity($community);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, CommunityMember::class, $useRelations, $withRelations);
}
public function countAllByCommunity(Community $community): int
{
return $this->selectAllByCommunity($community)->count();
}
public function getAllByUser(User $user, bool $useRelations = false, array $withRelations = []): Generator
{
$select = new Select(\Container::$dbConnection);
@ -37,4 +41,11 @@ class CommunityMemberRepository
return \Container::$persistentDataManager->selectFromDb($select, CommunityMember::class);
}
private function selectAllByCommunity(Community $community): Select
{
$select = new Select(\Container::$dbConnection, CommunityMember::getTable());
$select->where('community_id', '=', $community->getId());
return $select;
}
}