mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
remove article drafts (feature moved to new releases)
This commit is contained in:
parent
da1e869be5
commit
ea9f7f1589
35 changed files with 9 additions and 4606 deletions
|
|
@ -58,9 +58,6 @@ class ActivityService
|
|||
|
||||
Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD,
|
||||
Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD,
|
||||
|
||||
// Articles
|
||||
Activity::EVENT_ARTICLE_ADD,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -341,19 +338,6 @@ class ActivityService
|
|||
] = $code;
|
||||
|
||||
break;
|
||||
|
||||
// Article
|
||||
case Activity::EVENT_TORRENT_ADD:
|
||||
|
||||
$events
|
||||
[
|
||||
$this->translatorInterface->trans('Articles')
|
||||
]
|
||||
[
|
||||
$this->translatorInterface->trans('Added')
|
||||
] = $code;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -424,28 +408,6 @@ class ActivityService
|
|||
);
|
||||
}
|
||||
|
||||
public function findLastActivitiesByArticleId(
|
||||
int $articleId,
|
||||
array $whitelist,
|
||||
int $limit = 10,
|
||||
int $offset = 0
|
||||
): array
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(Activity::class)
|
||||
->findBy(
|
||||
[
|
||||
'articleId' => $articleId,
|
||||
'event' => $whitelist,
|
||||
],
|
||||
[
|
||||
'id' => 'DESC'
|
||||
],
|
||||
$limit,
|
||||
$offset
|
||||
);
|
||||
}
|
||||
|
||||
public function findActivitiesTotal(
|
||||
array $whitelist
|
||||
): int
|
||||
|
|
@ -481,19 +443,6 @@ class ActivityService
|
|||
);
|
||||
}
|
||||
|
||||
public function findActivitiesTotalByArticleId(
|
||||
int $articleId,
|
||||
array $whitelist
|
||||
): int
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(Activity::class)
|
||||
->findActivitiesTotalByArticleId(
|
||||
$articleId,
|
||||
$whitelist
|
||||
);
|
||||
}
|
||||
|
||||
// User
|
||||
public function addEventUserAdd(
|
||||
int $userId,
|
||||
|
|
|
|||
|
|
@ -1,196 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Article;
|
||||
use App\Entity\ArticleTitle;
|
||||
use App\Entity\ArticleDescription;
|
||||
use App\Entity\ArticleTorrents;
|
||||
use App\Entity\ArticleSensitive;
|
||||
|
||||
use App\Repository\ArticleRepository;
|
||||
use App\Repository\ArticleTitleRepository;
|
||||
use App\Repository\ArticleDescriptionRepository;
|
||||
use App\Repository\ArticleSensitiveRepository;
|
||||
use App\Repository\ArticleTorrentsRepository;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class ArticleService
|
||||
{
|
||||
private EntityManagerInterface $entityManager;
|
||||
private ParameterBagInterface $parameterBagInterface;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $entityManager,
|
||||
)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function submit(
|
||||
int $added,
|
||||
int $userId,
|
||||
string $locale,
|
||||
string $title,
|
||||
string $description,
|
||||
array $torrents,
|
||||
bool $sensitive,
|
||||
bool $approved
|
||||
): ?Article
|
||||
{
|
||||
$article = $this->addArticle();
|
||||
|
||||
if (!empty($title))
|
||||
{
|
||||
$articleTitle = $this->addArticleTitle(
|
||||
$article->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$locale,
|
||||
$title,
|
||||
$approved
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($description))
|
||||
{
|
||||
$articleDescription = $this->addArticleDescription(
|
||||
$article->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$locale,
|
||||
$description,
|
||||
$approved
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($torrents))
|
||||
{
|
||||
$articleTorrents = $this->addArticleTorrents(
|
||||
$article->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$locale,
|
||||
$torrents,
|
||||
$approved
|
||||
);
|
||||
}
|
||||
|
||||
// @TODO
|
||||
$articleSensitive = $this->addArticleSensitive(
|
||||
$article->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$locale,
|
||||
$description,
|
||||
$approved
|
||||
);
|
||||
|
||||
return $article;
|
||||
}
|
||||
|
||||
public function addArticle(): ?Article
|
||||
{
|
||||
$article = new Article();
|
||||
|
||||
$this->entityManager->persist($article);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $article;
|
||||
}
|
||||
|
||||
public function addArticleTitle(
|
||||
int $articleId,
|
||||
int $userId,
|
||||
int $added,
|
||||
string $locale,
|
||||
string $value,
|
||||
bool $approved
|
||||
): ?ArticleTitle
|
||||
{
|
||||
$articleTitle = new ArticleTitle();
|
||||
|
||||
$articleTitle->setArticleId($articleId);
|
||||
$articleTitle->setUserId($userId);
|
||||
$articleTitle->setLocale($locale);
|
||||
$articleTitle->setValue($value);
|
||||
$articleTitle->setAdded($added);
|
||||
$articleTitle->setApproved($approved);
|
||||
|
||||
$this->entityManager->persist($articleTitle);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $articleTitle;
|
||||
}
|
||||
|
||||
public function addArticleDescription(
|
||||
int $articleId,
|
||||
int $userId,
|
||||
int $added,
|
||||
string $locale,
|
||||
string $value,
|
||||
bool $approved
|
||||
): ?ArticleDescription
|
||||
{
|
||||
$articleDescription = new ArticleDescription();
|
||||
|
||||
$articleDescription->setArticleId($articleId);
|
||||
$articleDescription->setUserId($userId);
|
||||
$articleDescription->setAdded($added);
|
||||
$articleDescription->setLocale($locale);
|
||||
$articleDescription->setValue($value);
|
||||
$articleDescription->setApproved($approved);
|
||||
|
||||
$this->entityManager->persist($articleDescription);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $articleDescription;
|
||||
}
|
||||
|
||||
public function addArticleTorrents(
|
||||
int $articleId,
|
||||
int $userId,
|
||||
int $added,
|
||||
array $torrentsId,
|
||||
bool $approved
|
||||
): ?ArticleTorrents
|
||||
{
|
||||
$articleTorrents = new ArticleTorrents();
|
||||
|
||||
$articleTorrents->setArticleId($articleId);
|
||||
$articleTorrents->setUserId($userId);
|
||||
$articleTorrents->setAdded($added);
|
||||
$articleTorrents->setTorrentsId($torrentsId);
|
||||
$articleTorrents->setApproved($approved);
|
||||
|
||||
$this->entityManager->persist($articleTorrents);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $articleTorrents;
|
||||
}
|
||||
|
||||
public function addArticleSensitive(
|
||||
int $articleId,
|
||||
int $userId,
|
||||
int $added,
|
||||
string $locale,
|
||||
string $value,
|
||||
bool $approved
|
||||
): ?ArticleSensitive
|
||||
{
|
||||
$articleSensitive = new ArticleSensitive();
|
||||
|
||||
$articleSensitive->setArticleId($articleId);
|
||||
$articleSensitive->setUserId($userId);
|
||||
$articleSensitive->setAdded($added);
|
||||
$articleSensitive->setLocale($locale);
|
||||
$articleSensitive->setValue($value);
|
||||
$articleSensitive->setApproved($approved);
|
||||
|
||||
$this->entityManager->persist($articleSensitive);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $articleSensitive;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue