From c747166a30666a859bb47ee57cfc4eed77eb7ef6 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 10 Oct 2023 14:43:44 +0300 Subject: [PATCH] rename page to article --- config/services.yaml | 8 +- ...geController.php => ArticleController.php} | 66 +++--- src/Controller/SearchController.php | 8 +- src/Controller/TorrentController.php | 18 +- src/Controller/UserController.php | 12 +- src/Entity/Activity.php | 10 +- src/Entity/{Page.php => Article.php} | 6 +- ...Description.php => ArticleDescription.php} | 16 +- ...PageSensitive.php => ArticleSensitive.php} | 16 +- .../{PageTitle.php => ArticleTitle.php} | 16 +- .../{PageTorrents.php => ArticleTorrents.php} | 16 +- .../ArticleDescriptionRepository.php | 23 ++ src/Repository/ArticleRepository.php | 23 ++ src/Repository/ArticleSensitiveRepository.php | 23 ++ src/Repository/ArticleTitleRepository.php | 23 ++ src/Repository/ArticleTorrentsRepository.php | 23 ++ src/Repository/PageDescriptionRepository.php | 23 -- src/Repository/PageRepository.php | 23 -- src/Repository/PageSensitiveRepository.php | 23 -- src/Repository/PageTitleRepository.php | 23 -- src/Repository/PageTorrentsRepository.php | 23 -- src/Service/ArticleService.php | 196 ++++++++++++++++++ src/Service/PageService.php | 196 ------------------ .../default/{page => article}/info.html.twig | 0 .../{page => article}/submit.html.twig | 6 +- templates/default/search/module.html.twig | 6 +- templates/default/search/torrent.html.twig | 2 +- templates/default/torrent/info.html.twig | 8 +- templates/default/user/module.html.twig | 4 +- translations/messages+intl-icu.cs.xlf | 24 +-- translations/messages+intl-icu.de.xlf | 24 +-- translations/messages+intl-icu.en.xlf | 24 +-- translations/messages+intl-icu.eo.xlf | 24 +-- translations/messages+intl-icu.es.xlf | 24 +-- translations/messages+intl-icu.fr.xlf | 24 +-- translations/messages+intl-icu.he.xlf | 24 +-- translations/messages+intl-icu.it.xlf | 24 +-- translations/messages+intl-icu.ka.xlf | 24 +-- translations/messages+intl-icu.lv.xlf | 24 +-- translations/messages+intl-icu.pl.xlf | 24 +-- translations/messages+intl-icu.pt.xlf | 24 +-- translations/messages+intl-icu.ru.xlf | 24 +-- translations/messages+intl-icu.uk.xlf | 42 ++-- 43 files changed, 597 insertions(+), 597 deletions(-) rename src/Controller/{PageController.php => ArticleController.php} (74%) rename src/Entity/{Page.php => Article.php} (91%) rename src/Entity/{PageDescription.php => ArticleDescription.php} (83%) rename src/Entity/{PageSensitive.php => ArticleSensitive.php} (83%) rename src/Entity/{PageTitle.php => ArticleTitle.php} (84%) rename src/Entity/{PageTorrents.php => ArticleTorrents.php} (81%) create mode 100644 src/Repository/ArticleDescriptionRepository.php create mode 100644 src/Repository/ArticleRepository.php create mode 100644 src/Repository/ArticleSensitiveRepository.php create mode 100644 src/Repository/ArticleTitleRepository.php create mode 100644 src/Repository/ArticleTorrentsRepository.php delete mode 100644 src/Repository/PageDescriptionRepository.php delete mode 100644 src/Repository/PageRepository.php delete mode 100644 src/Repository/PageSensitiveRepository.php delete mode 100644 src/Repository/PageTitleRepository.php delete mode 100644 src/Repository/PageTorrentsRepository.php create mode 100644 src/Service/ArticleService.php delete mode 100644 src/Service/PageService.php rename templates/default/{page => article}/info.html.twig (100%) rename templates/default/{page => article}/submit.html.twig (97%) diff --git a/config/services.yaml b/config/services.yaml index 5b29831..fe1f1ea 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -12,10 +12,10 @@ parameters: app.themes: '%env(APP_THEMES)%' app.sensitive: '%env(APP_SENSITIVE)%' app.trackers: '%env(APP_TRACKERS)%' - app.page.title.length.min: '%env(APP_PAGE_TITLE_LENGTH_MIN)%' - app.page.title.length.max: '%env(APP_PAGE_TITLE_LENGTH_MAX)%' - app.page.description.length.min: '%env(APP_PAGE_DESCRIPTION_LENGTH_MIN)%' - app.page.description.length.max: '%env(APP_PAGE_DESCRIPTION_LENGTH_MAX)%' + app.article.title.length.min: '%env(APP_PAGE_TITLE_LENGTH_MIN)%' + app.article.title.length.max: '%env(APP_PAGE_TITLE_LENGTH_MAX)%' + app.article.description.length.min: '%env(APP_PAGE_DESCRIPTION_LENGTH_MIN)%' + app.article.description.length.max: '%env(APP_PAGE_DESCRIPTION_LENGTH_MAX)%' app.torrent.size.max: '%env(APP_TORRENT_FILE_SIZE_MAX)%' services: diff --git a/src/Controller/PageController.php b/src/Controller/ArticleController.php similarity index 74% rename from src/Controller/PageController.php rename to src/Controller/ArticleController.php index b913eb8..72f445c 100644 --- a/src/Controller/PageController.php +++ b/src/Controller/ArticleController.php @@ -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, diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php index 46ef48f..03e30da 100644 --- a/src/Controller/SearchController.php +++ b/src/Controller/SearchController.php @@ -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': diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index 282b8b2..806b675 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -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', [ diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 33ded61..425cbe5 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -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', [ diff --git a/src/Entity/Activity.php b/src/Entity/Activity.php index 3d27fef..2b370ab 100644 --- a/src/Entity/Activity.php +++ b/src/Entity/Activity.php @@ -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; } diff --git a/src/Entity/Page.php b/src/Entity/Article.php similarity index 91% rename from src/Entity/Page.php rename to src/Entity/Article.php index 0814927..5f21569 100644 --- a/src/Entity/Page.php +++ b/src/Entity/Article.php @@ -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] diff --git a/src/Entity/PageDescription.php b/src/Entity/ArticleDescription.php similarity index 83% rename from src/Entity/PageDescription.php rename to src/Entity/ArticleDescription.php index ae85a02..003441f 100644 --- a/src/Entity/PageDescription.php +++ b/src/Entity/ArticleDescription.php @@ -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; } diff --git a/src/Entity/PageSensitive.php b/src/Entity/ArticleSensitive.php similarity index 83% rename from src/Entity/PageSensitive.php rename to src/Entity/ArticleSensitive.php index 7af1e78..b9b14f7 100644 --- a/src/Entity/PageSensitive.php +++ b/src/Entity/ArticleSensitive.php @@ -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; } diff --git a/src/Entity/PageTitle.php b/src/Entity/ArticleTitle.php similarity index 84% rename from src/Entity/PageTitle.php rename to src/Entity/ArticleTitle.php index 1dbce61..2a1c00a 100644 --- a/src/Entity/PageTitle.php +++ b/src/Entity/ArticleTitle.php @@ -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; } diff --git a/src/Entity/PageTorrents.php b/src/Entity/ArticleTorrents.php similarity index 81% rename from src/Entity/PageTorrents.php rename to src/Entity/ArticleTorrents.php index 81a3811..22ab371 100644 --- a/src/Entity/PageTorrents.php +++ b/src/Entity/ArticleTorrents.php @@ -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; } diff --git a/src/Repository/ArticleDescriptionRepository.php b/src/Repository/ArticleDescriptionRepository.php new file mode 100644 index 0000000..46cbf7e --- /dev/null +++ b/src/Repository/ArticleDescriptionRepository.php @@ -0,0 +1,23 @@ + + * + * @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); + } +} diff --git a/src/Repository/ArticleRepository.php b/src/Repository/ArticleRepository.php new file mode 100644 index 0000000..31ce461 --- /dev/null +++ b/src/Repository/ArticleRepository.php @@ -0,0 +1,23 @@ + + * + * @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); + } +} diff --git a/src/Repository/ArticleSensitiveRepository.php b/src/Repository/ArticleSensitiveRepository.php new file mode 100644 index 0000000..5c09ca3 --- /dev/null +++ b/src/Repository/ArticleSensitiveRepository.php @@ -0,0 +1,23 @@ + + * + * @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); + } +} diff --git a/src/Repository/ArticleTitleRepository.php b/src/Repository/ArticleTitleRepository.php new file mode 100644 index 0000000..c83d3d1 --- /dev/null +++ b/src/Repository/ArticleTitleRepository.php @@ -0,0 +1,23 @@ + + * + * @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); + } +} diff --git a/src/Repository/ArticleTorrentsRepository.php b/src/Repository/ArticleTorrentsRepository.php new file mode 100644 index 0000000..d3e7d9e --- /dev/null +++ b/src/Repository/ArticleTorrentsRepository.php @@ -0,0 +1,23 @@ + + * + * @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); + } +} diff --git a/src/Repository/PageDescriptionRepository.php b/src/Repository/PageDescriptionRepository.php deleted file mode 100644 index 06d9036..0000000 --- a/src/Repository/PageDescriptionRepository.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * @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); - } -} diff --git a/src/Repository/PageRepository.php b/src/Repository/PageRepository.php deleted file mode 100644 index f0baa09..0000000 --- a/src/Repository/PageRepository.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * @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); - } -} diff --git a/src/Repository/PageSensitiveRepository.php b/src/Repository/PageSensitiveRepository.php deleted file mode 100644 index 9f8b321..0000000 --- a/src/Repository/PageSensitiveRepository.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * @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); - } -} diff --git a/src/Repository/PageTitleRepository.php b/src/Repository/PageTitleRepository.php deleted file mode 100644 index 346ccd2..0000000 --- a/src/Repository/PageTitleRepository.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * @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); - } -} diff --git a/src/Repository/PageTorrentsRepository.php b/src/Repository/PageTorrentsRepository.php deleted file mode 100644 index 01c6627..0000000 --- a/src/Repository/PageTorrentsRepository.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * @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); - } -} diff --git a/src/Service/ArticleService.php b/src/Service/ArticleService.php new file mode 100644 index 0000000..cdfaaa7 --- /dev/null +++ b/src/Service/ArticleService.php @@ -0,0 +1,196 @@ +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; + } +} \ No newline at end of file diff --git a/src/Service/PageService.php b/src/Service/PageService.php deleted file mode 100644 index 97da0a5..0000000 --- a/src/Service/PageService.php +++ /dev/null @@ -1,196 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/templates/default/page/info.html.twig b/templates/default/article/info.html.twig similarity index 100% rename from templates/default/page/info.html.twig rename to templates/default/article/info.html.twig diff --git a/templates/default/page/submit.html.twig b/templates/default/article/submit.html.twig similarity index 97% rename from templates/default/page/submit.html.twig rename to templates/default/article/submit.html.twig index 2264705..5b579fe 100644 --- a/templates/default/page/submit.html.twig +++ b/templates/default/article/submit.html.twig @@ -1,11 +1,11 @@ {% extends 'default/layout.html.twig' %} -{% block title %}{{'Submit page'|trans }} - {{ name }}{% endblock %} +{% block title %}{{'Submit article'|trans }} - {{ name }}{% endblock %} {% block main_content %}
-

{{'Submit page'|trans }}

+

{{'Submit article'|trans }}

-
+