implement torrent sensitive edit features #11

This commit is contained in:
ghost 2023-10-08 16:02:38 +03:00
parent cbda078c38
commit b81d973331
7 changed files with 499 additions and 108 deletions

View file

@ -141,7 +141,7 @@ class TorrentService
{
return $this->entityManagerInterface
->getRepository(TorrentSensitive::class)
->getTorrentLocales($id);
->getTorrentSensitive($id);
}
public function findLastTorrentSensitive(int $torrentId): ?TorrentSensitive
@ -175,6 +175,22 @@ class TorrentService
return $torrentLocales;
}
public function toggleTorrentSensitiveApproved(
int $id
): ?TorrentSensitive
{
$torrentSensitive = $this->getTorrentSensitive($id);
$torrentSensitive->setApproved(
!$torrentSensitive->isApproved() // toggle current value
);
$this->entityManagerInterface->persist($torrentSensitive);
$this->entityManagerInterface->flush();
return $torrentSensitive;
}
// Delete
public function deleteTorrentLocales(
int $id
@ -188,6 +204,18 @@ class TorrentService
return $torrentLocales;
}
public function deleteTorrentSensitive(
int $id
): ?TorrentSensitive
{
$torrentSensitive = $this->getTorrentSensitive($id);
$this->entityManagerInterface->remove($torrentSensitive);
$this->entityManagerInterface->flush();
return $torrentSensitive;
}
// Setters
public function add(
string $filepath,