|
|
|
@ -161,16 +161,21 @@ class TorrentService
@@ -161,16 +161,21 @@ class TorrentService
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Bookmark |
|
|
|
|
public function findUserLastTorrentBookmarkValue(int $torrentId, int $userId): bool |
|
|
|
|
public function findTorrentBookmark( |
|
|
|
|
int $torrentId, |
|
|
|
|
int $userId |
|
|
|
|
): ?TorrentBookmark |
|
|
|
|
{ |
|
|
|
|
if ($torrentBookmark = $this->entityManagerInterface |
|
|
|
|
->getRepository(TorrentBookmark::class) |
|
|
|
|
->findUserLastTorrentBookmark($torrentId, $userId)) |
|
|
|
|
{ |
|
|
|
|
return $torrentBookmark->isValue(); |
|
|
|
|
} |
|
|
|
|
return $this->entityManagerInterface |
|
|
|
|
->getRepository(TorrentBookmark::class) |
|
|
|
|
->findTorrentBookmark($torrentId, $userId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
public function findTorrentBookmarksTotalByTorrentId(int $torrentId): int |
|
|
|
|
{ |
|
|
|
|
return $this->entityManagerInterface |
|
|
|
|
->getRepository(TorrentBookmark::class) |
|
|
|
|
->findTorrentBookmarksTotalByTorrentId($torrentId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Update |
|
|
|
@ -223,25 +228,25 @@ class TorrentService
@@ -223,25 +228,25 @@ class TorrentService
|
|
|
|
|
int $torrentId, |
|
|
|
|
int $userId, |
|
|
|
|
int $added |
|
|
|
|
): ?TorrentBookmark |
|
|
|
|
): void |
|
|
|
|
{ |
|
|
|
|
$torrentBookmark = new TorrentBookmark(); |
|
|
|
|
|
|
|
|
|
$torrentBookmark->setTorrentId($torrentId); |
|
|
|
|
$torrentBookmark->setUserId($userId); |
|
|
|
|
$torrentBookmark->setAdded($added); |
|
|
|
|
if ($torrentBookmark = $this->findTorrentBookmark($torrentId, $userId)) |
|
|
|
|
{ |
|
|
|
|
$this->entityManagerInterface->remove($torrentBookmark); |
|
|
|
|
$this->entityManagerInterface->flush(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$torrentBookmark->setValue( |
|
|
|
|
!$this->findUserLastTorrentBookmarkValue( |
|
|
|
|
$torrentId, |
|
|
|
|
$userId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$torrentBookmark = new TorrentBookmark(); |
|
|
|
|
|
|
|
|
|
$this->entityManagerInterface->persist($torrentBookmark); |
|
|
|
|
$this->entityManagerInterface->flush(); |
|
|
|
|
$torrentBookmark->setTorrentId($torrentId); |
|
|
|
|
$torrentBookmark->setUserId($userId); |
|
|
|
|
$torrentBookmark->setAdded($added); |
|
|
|
|
|
|
|
|
|
return $torrentBookmark; |
|
|
|
|
$this->entityManagerInterface->persist($torrentBookmark); |
|
|
|
|
$this->entityManagerInterface->flush(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function deleteTorrentSensitive( |
|
|
|
|