mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
rename page to article
This commit is contained in:
parent
649838d4ee
commit
c747166a30
43 changed files with 597 additions and 597 deletions
|
|
@ -10,14 +10,14 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use App\Service\UserService;
|
||||
use App\Service\PageService;
|
||||
use App\Service\ArticleService;
|
||||
use App\Service\TorrentService;
|
||||
|
||||
class PageController extends AbstractController
|
||||
class ArticleController extends AbstractController
|
||||
{
|
||||
#[Route(
|
||||
'/{_locale}/page/{id}',
|
||||
name: 'page_info',
|
||||
'/{_locale}/article/{id}',
|
||||
name: 'article_info',
|
||||
requirements:
|
||||
[
|
||||
'id' => '\d+'
|
||||
|
|
@ -38,14 +38,14 @@ class PageController extends AbstractController
|
|||
$request->getClientIp()
|
||||
);
|
||||
|
||||
return $this->render('default/page/info.html.twig', [
|
||||
return $this->render('default/article/info.html.twig', [
|
||||
'title' => 'test'
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/submit/page',
|
||||
name: 'page_submit',
|
||||
'/{_locale}/submit/article',
|
||||
name: 'article_submit',
|
||||
methods:
|
||||
[
|
||||
'GET',
|
||||
|
|
@ -56,8 +56,8 @@ class PageController extends AbstractController
|
|||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
PageService $pageService,
|
||||
PageService $torrentService
|
||||
ArticleService $articleService,
|
||||
ArticleService $torrentService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
|
|
@ -91,12 +91,12 @@ class PageController extends AbstractController
|
|||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('title'),
|
||||
'minlength' => $this->getParameter('app.page.title.length.min'),
|
||||
'maxlength' => $this->getParameter('app.page.title.length.max'),
|
||||
'minlength' => $this->getParameter('app.article.title.length.min'),
|
||||
'maxlength' => $this->getParameter('app.article.title.length.max'),
|
||||
'placeholder' => sprintf(
|
||||
$translator->trans('Page title (%s-%s chars)'),
|
||||
number_format($this->getParameter('app.page.title.length.min')),
|
||||
number_format($this->getParameter('app.page.title.length.max'))
|
||||
$translator->trans('Article title (%s-%s chars)'),
|
||||
number_format($this->getParameter('app.article.title.length.min')),
|
||||
number_format($this->getParameter('app.article.title.length.max'))
|
||||
),
|
||||
]
|
||||
],
|
||||
|
|
@ -106,12 +106,12 @@ class PageController extends AbstractController
|
|||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('description'),
|
||||
'minlength' => $this->getParameter('app.page.description.length.min'),
|
||||
'maxlength' => $this->getParameter('app.page.description.length.max'),
|
||||
'minlength' => $this->getParameter('app.article.description.length.min'),
|
||||
'maxlength' => $this->getParameter('app.article.description.length.max'),
|
||||
'placeholder' => sprintf(
|
||||
$translator->trans('Page description (%s-%s chars)'),
|
||||
number_format($this->getParameter('app.page.description.length.min')),
|
||||
number_format($this->getParameter('app.page.description.length.max'))
|
||||
$translator->trans('Article description (%s-%s chars)'),
|
||||
number_format($this->getParameter('app.article.description.length.min')),
|
||||
number_format($this->getParameter('app.article.description.length.max'))
|
||||
),
|
||||
]
|
||||
],
|
||||
|
|
@ -144,24 +144,24 @@ class PageController extends AbstractController
|
|||
}
|
||||
|
||||
/// Title
|
||||
if (mb_strlen($request->get('title')) < $this->getParameter('app.page.title.length.min') ||
|
||||
mb_strlen($request->get('title')) > $this->getParameter('app.page.title.length.max'))
|
||||
if (mb_strlen($request->get('title')) < $this->getParameter('app.article.title.length.min') ||
|
||||
mb_strlen($request->get('title')) > $this->getParameter('app.article.title.length.max'))
|
||||
{
|
||||
$form['title']['error'][] = sprintf(
|
||||
$translator->trans('Page title out of %s-%s chars'),
|
||||
number_format($this->getParameter('app.page.title.length.min')),
|
||||
number_format($this->getParameter('app.page.title.length.max'))
|
||||
$translator->trans('Article title out of %s-%s chars'),
|
||||
number_format($this->getParameter('app.article.title.length.min')),
|
||||
number_format($this->getParameter('app.article.title.length.max'))
|
||||
);
|
||||
}
|
||||
|
||||
/// Description
|
||||
if (mb_strlen($request->get('description')) < $this->getParameter('app.page.description.length.min') ||
|
||||
mb_strlen($request->get('description')) > $this->getParameter('app.page.description.length.max'))
|
||||
if (mb_strlen($request->get('description')) < $this->getParameter('app.article.description.length.min') ||
|
||||
mb_strlen($request->get('description')) > $this->getParameter('app.article.description.length.max'))
|
||||
{
|
||||
$form['description']['error'][] = sprintf(
|
||||
$translator->trans('Page description out of %s-%s chars'),
|
||||
number_format($this->getParameter('app.page.description.length.min')),
|
||||
number_format($this->getParameter('app.page.description.length.max'))
|
||||
$translator->trans('Article description out of %s-%s chars'),
|
||||
number_format($this->getParameter('app.article.description.length.min')),
|
||||
number_format($this->getParameter('app.article.description.length.max'))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ class PageController extends AbstractController
|
|||
empty($form['torrents']['error'])
|
||||
)
|
||||
{
|
||||
$page = $pageService->submit(
|
||||
$article = $articleService->submit(
|
||||
$user->getId(),
|
||||
time(),
|
||||
(string) $request->get('locale'),
|
||||
|
|
@ -225,17 +225,17 @@ class PageController extends AbstractController
|
|||
|
||||
// Redirect
|
||||
return $this->redirectToRoute(
|
||||
'page_info',
|
||||
'article_info',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'id' => $page->getId()
|
||||
'id' => $article->getId()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'default/page/submit.html.twig',
|
||||
'default/article/submit.html.twig',
|
||||
[
|
||||
'locales' => explode('|', $this->getParameter('app.locales')),
|
||||
'form' => $form,
|
||||
|
|
@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use App\Service\UserService;
|
||||
use App\Service\PageService;
|
||||
use App\Service\ArticleService;
|
||||
use App\Service\TorrentService;
|
||||
|
||||
class SearchController extends AbstractController
|
||||
|
|
@ -25,7 +25,7 @@ class SearchController extends AbstractController
|
|||
public function index(
|
||||
Request $request,
|
||||
UserService $userService,
|
||||
PageService $pageService,
|
||||
ArticleService $articleService,
|
||||
TorrentService $torrentService
|
||||
): Response
|
||||
{
|
||||
|
|
@ -34,11 +34,11 @@ class SearchController extends AbstractController
|
|||
$request->getClientIp()
|
||||
);
|
||||
|
||||
$page = $request->query->get('page') ? (int) $request->query->get('page') : 1;
|
||||
$article = $request->query->get('article') ? (int) $request->query->get('article') : 1;
|
||||
|
||||
switch ($request->query->get('type'))
|
||||
{
|
||||
case 'page':
|
||||
case 'article':
|
||||
|
||||
break;
|
||||
case 'torrent':
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ class TorrentController extends AbstractController
|
|||
$torrent->getId()
|
||||
)
|
||||
],
|
||||
'pages' => [],
|
||||
'articles' => [],
|
||||
'contributors' => $contributors
|
||||
],
|
||||
'file' =>
|
||||
|
|
@ -282,7 +282,7 @@ class TorrentController extends AbstractController
|
|||
$user->isApproved()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
[
|
||||
|
|
@ -465,7 +465,7 @@ class TorrentController extends AbstractController
|
|||
$user->isApproved()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
[
|
||||
|
|
@ -544,7 +544,7 @@ class TorrentController extends AbstractController
|
|||
$torrentLocales->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_locales_edit',
|
||||
[
|
||||
|
|
@ -606,7 +606,7 @@ class TorrentController extends AbstractController
|
|||
$torrentLocales->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_locales_edit',
|
||||
[
|
||||
|
|
@ -751,7 +751,7 @@ class TorrentController extends AbstractController
|
|||
$user->isApproved()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
[
|
||||
|
|
@ -828,7 +828,7 @@ class TorrentController extends AbstractController
|
|||
$torrentSensitive->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_sensitive_edit',
|
||||
[
|
||||
|
|
@ -890,7 +890,7 @@ class TorrentController extends AbstractController
|
|||
$torrentSensitive->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_sensitive_edit',
|
||||
[
|
||||
|
|
@ -947,7 +947,7 @@ class TorrentController extends AbstractController
|
|||
time()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
[
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
|
||||
use App\Service\ActivityService;
|
||||
use App\Service\UserService;
|
||||
use App\Service\PageService;
|
||||
use App\Service\ArticleService;
|
||||
use App\Service\TorrentService;
|
||||
|
||||
class UserController extends AbstractController
|
||||
|
|
@ -300,7 +300,7 @@ class UserController extends AbstractController
|
|||
time()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'user_info',
|
||||
[
|
||||
|
|
@ -352,7 +352,7 @@ class UserController extends AbstractController
|
|||
$userTarget->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'user_info',
|
||||
[
|
||||
|
|
@ -404,7 +404,7 @@ class UserController extends AbstractController
|
|||
$userTarget->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'user_info',
|
||||
[
|
||||
|
|
@ -430,7 +430,7 @@ class UserController extends AbstractController
|
|||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
PageService $pageService,
|
||||
ArticleService $articleService,
|
||||
TorrentService $torrentService
|
||||
): Response
|
||||
{
|
||||
|
|
@ -477,7 +477,7 @@ class UserController extends AbstractController
|
|||
$userTarget->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'user_info',
|
||||
[
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Activity
|
|||
private ?int $userId = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $pageId = null;
|
||||
private ?int $articleId = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
|
|
@ -80,14 +80,14 @@ class Activity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getPageId(): ?int
|
||||
public function getArticleId(): ?int
|
||||
{
|
||||
return $this->pageId;
|
||||
return $this->articleId;
|
||||
}
|
||||
|
||||
public function setPageId(?int $pageId): static
|
||||
public function setArticleId(?int $articleId): static
|
||||
{
|
||||
$this->pageId = $pageId;
|
||||
$this->articleId = $articleId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PageRepository;
|
||||
use App\Repository\ArticleRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PageRepository::class)]
|
||||
class Page
|
||||
#[ORM\Entity(repositoryClass: ArticleRepository::class)]
|
||||
class Article
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PageDescriptionRepository;
|
||||
use App\Repository\ArticleDescriptionRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PageDescriptionRepository::class)]
|
||||
class PageDescription
|
||||
#[ORM\Entity(repositoryClass: ArticleDescriptionRepository::class)]
|
||||
class ArticleDescription
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
|
|
@ -15,7 +15,7 @@ class PageDescription
|
|||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $pageId = null;
|
||||
private ?int $articleId = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $userId = null;
|
||||
|
|
@ -44,14 +44,14 @@ class PageDescription
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getPageId(): ?int
|
||||
public function getArticleId(): ?int
|
||||
{
|
||||
return $this->pageId;
|
||||
return $this->articleId;
|
||||
}
|
||||
|
||||
public function setPageId(int $pageId): static
|
||||
public function setArticleId(int $articleId): static
|
||||
{
|
||||
$this->pageId = $pageId;
|
||||
$this->articleId = $articleId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PageSensitiveRepository;
|
||||
use App\Repository\ArticleSensitiveRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PageSensitiveRepository::class)]
|
||||
class PageSensitive
|
||||
#[ORM\Entity(repositoryClass: ArticleSensitiveRepository::class)]
|
||||
class ArticleSensitive
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
|
|
@ -15,7 +15,7 @@ class PageSensitive
|
|||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $pageId = null;
|
||||
private ?int $articleId = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $userId = null;
|
||||
|
|
@ -44,14 +44,14 @@ class PageSensitive
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getPageId(): ?int
|
||||
public function getArticleId(): ?int
|
||||
{
|
||||
return $this->pageId;
|
||||
return $this->articleId;
|
||||
}
|
||||
|
||||
public function setPageId(int $pageId): static
|
||||
public function setArticleId(int $articleId): static
|
||||
{
|
||||
$this->pageId = $pageId;
|
||||
$this->articleId = $articleId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PageTitleRepository;
|
||||
use App\Repository\ArticleTitleRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PageTitleRepository::class)]
|
||||
class PageTitle
|
||||
#[ORM\Entity(repositoryClass: ArticleTitleRepository::class)]
|
||||
class ArticleTitle
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
|
|
@ -15,7 +15,7 @@ class PageTitle
|
|||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $pageId = null;
|
||||
private ?int $articleId = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $userId = null;
|
||||
|
|
@ -44,14 +44,14 @@ class PageTitle
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getPageId(): ?int
|
||||
public function getArticleId(): ?int
|
||||
{
|
||||
return $this->pageId;
|
||||
return $this->articleId;
|
||||
}
|
||||
|
||||
public function setPageId(int $pageId): static
|
||||
public function setArticleId(int $articleId): static
|
||||
{
|
||||
$this->pageId = $pageId;
|
||||
$this->articleId = $articleId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PageTorrentsRepository;
|
||||
use App\Repository\ArticleTorrentsRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PageTorrentsRepository::class)]
|
||||
class PageTorrents
|
||||
#[ORM\Entity(repositoryClass: ArticleTorrentsRepository::class)]
|
||||
class ArticleTorrents
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
|
|
@ -15,7 +15,7 @@ class PageTorrents
|
|||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $pageId = null;
|
||||
private ?int $articleId = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $userId = null;
|
||||
|
|
@ -41,14 +41,14 @@ class PageTorrents
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getPageId(): ?int
|
||||
public function getArticleId(): ?int
|
||||
{
|
||||
return $this->pageId;
|
||||
return $this->articleId;
|
||||
}
|
||||
|
||||
public function setPageId(int $pageId): static
|
||||
public function setArticleId(int $articleId): static
|
||||
{
|
||||
$this->pageId = $pageId;
|
||||
$this->articleId = $articleId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
23
src/Repository/ArticleDescriptionRepository.php
Normal file
23
src/Repository/ArticleDescriptionRepository.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\ArticleDescription;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<ArticleDescription>
|
||||
*
|
||||
* @method ArticleDescription|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method ArticleDescription|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method ArticleDescription[] findAll()
|
||||
* @method ArticleDescription[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ArticleDescriptionRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, ArticleDescription::class);
|
||||
}
|
||||
}
|
||||
23
src/Repository/ArticleRepository.php
Normal file
23
src/Repository/ArticleRepository.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Article;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Article>
|
||||
*
|
||||
* @method Article|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Article|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Article[] findAll()
|
||||
* @method Article[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ArticleRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Article::class);
|
||||
}
|
||||
}
|
||||
23
src/Repository/ArticleSensitiveRepository.php
Normal file
23
src/Repository/ArticleSensitiveRepository.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\ArticleSensitive;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<ArticleSensitive>
|
||||
*
|
||||
* @method ArticleSensitive|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method ArticleSensitive|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method ArticleSensitive[] findAll()
|
||||
* @method ArticleSensitive[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ArticleSensitiveRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, ArticleSensitive::class);
|
||||
}
|
||||
}
|
||||
23
src/Repository/ArticleTitleRepository.php
Normal file
23
src/Repository/ArticleTitleRepository.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\ArticleTitle;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<ArticleTitle>
|
||||
*
|
||||
* @method ArticleTitle|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method ArticleTitle|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method ArticleTitle[] findAll()
|
||||
* @method ArticleTitle[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ArticleTitleRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, ArticleTitle::class);
|
||||
}
|
||||
}
|
||||
23
src/Repository/ArticleTorrentsRepository.php
Normal file
23
src/Repository/ArticleTorrentsRepository.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\ArticleTorrents;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<ArticleTorrents>
|
||||
*
|
||||
* @method ArticleTorrents|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method ArticleTorrents|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method ArticleTorrents[] findAll()
|
||||
* @method ArticleTorrents[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ArticleTorrentsRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, ArticleTorrents::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PageDescription;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<PageDescription>
|
||||
*
|
||||
* @method PageDescription|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PageDescription|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PageDescription[] findAll()
|
||||
* @method PageDescription[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PageDescriptionRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PageDescription::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Page;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Page>
|
||||
*
|
||||
* @method Page|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Page|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Page[] findAll()
|
||||
* @method Page[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PageRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Page::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PageSensitive;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<PageSensitive>
|
||||
*
|
||||
* @method PageSensitive|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PageSensitive|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PageSensitive[] findAll()
|
||||
* @method PageSensitive[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PageSensitiveRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PageSensitive::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PageTitle;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<PageTitle>
|
||||
*
|
||||
* @method PageTitle|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PageTitle|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PageTitle[] findAll()
|
||||
* @method PageTitle[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PageTitleRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PageTitle::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PageTorrents;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<PageTorrents>
|
||||
*
|
||||
* @method PageTorrents|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PageTorrents|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PageTorrents[] findAll()
|
||||
* @method PageTorrents[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PageTorrentsRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PageTorrents::class);
|
||||
}
|
||||
}
|
||||
196
src/Service/ArticleService.php
Normal file
196
src/Service/ArticleService.php
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,196 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Page;
|
||||
use App\Entity\PageTitle;
|
||||
use App\Entity\PageDescription;
|
||||
use App\Entity\PageTorrents;
|
||||
use App\Entity\PageSensitive;
|
||||
|
||||
use App\Repository\PageRepository;
|
||||
use App\Repository\PageTitleRepository;
|
||||
use App\Repository\PageDescriptionRepository;
|
||||
use App\Repository\PageSensitiveRepository;
|
||||
use App\Repository\PageTorrentsRepository;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class PageService
|
||||
{
|
||||
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
|
||||
): ?Page
|
||||
{
|
||||
$page = $this->addPage();
|
||||
|
||||
if (!empty($title))
|
||||
{
|
||||
$pageTitle = $this->addPageTitle(
|
||||
$page->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$locale,
|
||||
$title,
|
||||
$approved
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($description))
|
||||
{
|
||||
$pageDescription = $this->addPageDescription(
|
||||
$page->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$locale,
|
||||
$description,
|
||||
$approved
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($torrents))
|
||||
{
|
||||
$pageTorrents = $this->addPageTorrents(
|
||||
$page->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$locale,
|
||||
$torrents,
|
||||
$approved
|
||||
);
|
||||
}
|
||||
|
||||
// @TODO
|
||||
$pageSensitive = $this->addPageSensitive(
|
||||
$page->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$locale,
|
||||
$description,
|
||||
$approved
|
||||
);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function addPage(): ?Page
|
||||
{
|
||||
$page = new Page();
|
||||
|
||||
$this->entityManager->persist($page);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function addPageTitle(
|
||||
int $pageId,
|
||||
int $userId,
|
||||
int $added,
|
||||
string $locale,
|
||||
string $value,
|
||||
bool $approved
|
||||
): ?PageTitle
|
||||
{
|
||||
$pageTitle = new PageTitle();
|
||||
|
||||
$pageTitle->setPageId($pageId);
|
||||
$pageTitle->setUserId($userId);
|
||||
$pageTitle->setLocale($locale);
|
||||
$pageTitle->setValue($value);
|
||||
$pageTitle->setAdded($added);
|
||||
$pageTitle->setApproved($approved);
|
||||
|
||||
$this->entityManager->persist($pageTitle);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $pageTitle;
|
||||
}
|
||||
|
||||
public function addPageDescription(
|
||||
int $pageId,
|
||||
int $userId,
|
||||
int $added,
|
||||
string $locale,
|
||||
string $value,
|
||||
bool $approved
|
||||
): ?PageDescription
|
||||
{
|
||||
$pageDescription = new PageDescription();
|
||||
|
||||
$pageDescription->setPageId($pageId);
|
||||
$pageDescription->setUserId($userId);
|
||||
$pageDescription->setAdded($added);
|
||||
$pageDescription->setLocale($locale);
|
||||
$pageDescription->setValue($value);
|
||||
$pageDescription->setApproved($approved);
|
||||
|
||||
$this->entityManager->persist($pageDescription);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $pageDescription;
|
||||
}
|
||||
|
||||
public function addPageTorrents(
|
||||
int $pageId,
|
||||
int $userId,
|
||||
int $added,
|
||||
array $torrentsId,
|
||||
bool $approved
|
||||
): ?PageTorrents
|
||||
{
|
||||
$pageTorrents = new PageTorrents();
|
||||
|
||||
$pageTorrents->setPageId($pageId);
|
||||
$pageTorrents->setUserId($userId);
|
||||
$pageTorrents->setAdded($added);
|
||||
$pageTorrents->setTorrentsId($torrentsId);
|
||||
$pageTorrents->setApproved($approved);
|
||||
|
||||
$this->entityManager->persist($pageTorrents);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $pageTorrents;
|
||||
}
|
||||
|
||||
public function addPageSensitive(
|
||||
int $pageId,
|
||||
int $userId,
|
||||
int $added,
|
||||
string $locale,
|
||||
string $value,
|
||||
bool $approved
|
||||
): ?PageSensitive
|
||||
{
|
||||
$pageSensitive = new PageSensitive();
|
||||
|
||||
$pageSensitive->setPageId($pageId);
|
||||
$pageSensitive->setUserId($userId);
|
||||
$pageSensitive->setAdded($added);
|
||||
$pageSensitive->setLocale($locale);
|
||||
$pageSensitive->setValue($value);
|
||||
$pageSensitive->setApproved($approved);
|
||||
|
||||
$this->entityManager->persist($pageSensitive);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $pageSensitive;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue