adapt Container usage to new soko-web
rvr-nextgen/pipeline/pr-master This commit looks good

This commit is contained in:
bence committed 2023-04-19 23:38:43 +02:00
1 parent 36f767ea9b
commit dccb34971b
20 files changed
+135 -237

No files matched your search

+4 -12
View File
@@ -5,20 +5,12 @@ use RVR\PersistentData\Model\Community;
use RVR\PersistentData\Model\CommunityMember;
use RVR\PersistentData\Model\User;
use SokoWeb\Database\Query\Select;
use SokoWeb\PersistentData\PersistentDataManager;
class CommunityMemberRepository
{
private PersistentDataManager $pdm;
public function __construct()
{
$this->pdm = new PersistentDataManager();
}
public function getById(int $id): ?CommunityMember
{
return $this->pdm->selectFromDbById($id, CommunityMember::class);
return \Container::$persistentDataManager->selectFromDbById($id, CommunityMember::class);
}
public function getAllByCommunity(Community $community, bool $useRelations = false): Generator
@@ -26,7 +18,7 @@ class CommunityMemberRepository
$select = new Select(\Container::$dbConnection);
$select->where('community_id', '=', $community->getId());
yield from $this->pdm->selectMultipleFromDb($select, CommunityMember::class, $useRelations);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, CommunityMember::class, $useRelations);
}
public function getAllByUser(User $user, bool $useRelations = false): Generator
@@ -34,7 +26,7 @@ class CommunityMemberRepository
$select = new Select(\Container::$dbConnection);
$select->where('user_id', '=', $user->getId());
yield from $this->pdm->selectMultipleFromDb($select, CommunityMember::class, $useRelations);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, CommunityMember::class, $useRelations);
}
public function getByCommunityAndUser(Community $community, User $user) : ?CommunityMember
@@ -43,6 +35,6 @@ class CommunityMemberRepository
$select->where('community_id', '=', $community->getId());
$select->where('user_id', '=', $user->getId());
return $this->pdm->selectFromDb($select, CommunityMember::class);
return \Container::$persistentDataManager->selectFromDb($select, CommunityMember::class);
}
}