ghost
1 year ago
22 changed files with 1048 additions and 101 deletions
@ -0,0 +1,99 @@
@@ -0,0 +1,99 @@
|
||||
<?php |
||||
|
||||
namespace App\Entity; |
||||
|
||||
use App\Repository\ActivityRepository; |
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
#[ORM\Entity(repositoryClass: ActivityRepository::class)] |
||||
class Activity |
||||
{ |
||||
#[ORM\Id] |
||||
#[ORM\GeneratedValue] |
||||
#[ORM\Column] |
||||
private ?int $id = null; |
||||
|
||||
#[ORM\Column(length: 255)] |
||||
private ?string $event = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $added = null; |
||||
|
||||
#[ORM\Column(nullable: true)] |
||||
private ?int $userId = null; |
||||
|
||||
#[ORM\Column(nullable: true)] |
||||
private ?int $pageId = null; |
||||
|
||||
public function getId(): ?int |
||||
{ |
||||
return $this->id; |
||||
} |
||||
|
||||
public function setId(string $id): static |
||||
{ |
||||
$this->id = $id; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getEvent(): ?string |
||||
{ |
||||
return $this->event; |
||||
} |
||||
|
||||
public function setEvent(string $event): static |
||||
{ |
||||
$this->event = $event; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getAdded(): ?int |
||||
{ |
||||
return $this->added; |
||||
} |
||||
|
||||
public function setAdded(int $added): static |
||||
{ |
||||
$this->added = $added; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function setApproved(bool $approved): static |
||||
{ |
||||
$this->approved = $approved; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getUserId(): ?int |
||||
{ |
||||
return $this->userId; |
||||
} |
||||
|
||||
public function setUserId(?int $userId): static |
||||
{ |
||||
$this->userId = $userId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getPageId(): ?int |
||||
{ |
||||
return $this->pageId; |
||||
} |
||||
|
||||
public function setPageId(?int $pageId): static |
||||
{ |
||||
$this->pageId = $pageId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function isApproved(): ?bool |
||||
{ |
||||
return $this->approved; |
||||
} |
||||
} |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
<?php |
||||
|
||||
namespace App\Entity; |
||||
|
||||
use App\Repository\PageDescriptionRepository; |
||||
use Doctrine\DBAL\Types\Types; |
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
#[ORM\Entity(repositoryClass: PageDescriptionRepository::class)] |
||||
class PageDescription |
||||
{ |
||||
#[ORM\Id] |
||||
#[ORM\GeneratedValue] |
||||
#[ORM\Column] |
||||
private ?int $id = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $pageId = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $userId = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $added = null; |
||||
|
||||
#[ORM\Column(length: 255)] |
||||
private ?string $locale = null; |
||||
|
||||
#[ORM\Column(type: Types::TEXT)] |
||||
private ?string $value = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?bool $approved = null; |
||||
|
||||
public function getId(): ?int |
||||
{ |
||||
return $this->id; |
||||
} |
||||
|
||||
public function setId(string $id): static |
||||
{ |
||||
$this->id = $id; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getPageId(): ?int |
||||
{ |
||||
return $this->pageId; |
||||
} |
||||
|
||||
public function setPageId(int $pageId): static |
||||
{ |
||||
$this->pageId = $pageId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getUserId(): ?int |
||||
{ |
||||
return $this->userId; |
||||
} |
||||
|
||||
public function setUserId(int $userId): static |
||||
{ |
||||
$this->userId = $userId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getAdded(): ?int |
||||
{ |
||||
return $this->added; |
||||
} |
||||
|
||||
public function setAdded(int $added): static |
||||
{ |
||||
$this->added = $added; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getLocale(): ?string |
||||
{ |
||||
return $this->locale; |
||||
} |
||||
|
||||
public function setLocale(string $locale): static |
||||
{ |
||||
$this->locale = $locale; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getValue(): ?string |
||||
{ |
||||
return $this->value; |
||||
} |
||||
|
||||
public function setValue(string $value): static |
||||
{ |
||||
$this->value = $value; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function isApproved(): ?bool |
||||
{ |
||||
return $this->approved; |
||||
} |
||||
|
||||
public function setApproved(bool $approved): static |
||||
{ |
||||
$this->approved = $approved; |
||||
|
||||
return $this; |
||||
} |
||||
} |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
<?php |
||||
|
||||
namespace App\Entity; |
||||
|
||||
use App\Repository\PageSensitiveRepository; |
||||
use Doctrine\DBAL\Types\Types; |
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
#[ORM\Entity(repositoryClass: PageSensitiveRepository::class)] |
||||
class PageSensitive |
||||
{ |
||||
#[ORM\Id] |
||||
#[ORM\GeneratedValue] |
||||
#[ORM\Column] |
||||
private ?int $id = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $pageId = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $userId = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $added = null; |
||||
|
||||
#[ORM\Column(length: 255)] |
||||
private ?string $locale = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?bool $value = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?bool $approved = null; |
||||
|
||||
public function getId(): ?int |
||||
{ |
||||
return $this->id; |
||||
} |
||||
|
||||
public function setId(string $id): static |
||||
{ |
||||
$this->id = $id; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getPageId(): ?int |
||||
{ |
||||
return $this->pageId; |
||||
} |
||||
|
||||
public function setPageId(int $pageId): static |
||||
{ |
||||
$this->pageId = $pageId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getUserId(): ?int |
||||
{ |
||||
return $this->userId; |
||||
} |
||||
|
||||
public function setUserId(int $userId): static |
||||
{ |
||||
$this->userId = $userId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getAdded(): ?int |
||||
{ |
||||
return $this->added; |
||||
} |
||||
|
||||
public function setAdded(int $added): static |
||||
{ |
||||
$this->added = $added; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getLocale(): ?string |
||||
{ |
||||
return $this->locale; |
||||
} |
||||
|
||||
public function setLocale(string $locale): static |
||||
{ |
||||
$this->locale = $locale; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function isValue(): ?bool |
||||
{ |
||||
return $this->value; |
||||
} |
||||
|
||||
public function setValue(bool $value): static |
||||
{ |
||||
$this->value = $value; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function isApproved(): ?bool |
||||
{ |
||||
return $this->approved; |
||||
} |
||||
|
||||
public function setApproved(bool $approved): static |
||||
{ |
||||
$this->approved = $approved; |
||||
|
||||
return $this; |
||||
} |
||||
} |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
<?php |
||||
|
||||
namespace App\Entity; |
||||
|
||||
use App\Repository\PageTitleRepository; |
||||
use Doctrine\DBAL\Types\Types; |
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
#[ORM\Entity(repositoryClass: PageTitleRepository::class)] |
||||
class PageTitle |
||||
{ |
||||
#[ORM\Id] |
||||
#[ORM\GeneratedValue] |
||||
#[ORM\Column] |
||||
private ?int $id = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $pageId = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $userId = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $added = null; |
||||
|
||||
#[ORM\Column(length: 255)] |
||||
private ?string $locale = null; |
||||
|
||||
#[ORM\Column(type: Types::TEXT)] |
||||
private ?string $value = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?bool $approved = null; |
||||
|
||||
public function getId(): ?int |
||||
{ |
||||
return $this->id; |
||||
} |
||||
|
||||
public function setId(string $id): static |
||||
{ |
||||
$this->id = $id; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getPageId(): ?int |
||||
{ |
||||
return $this->pageId; |
||||
} |
||||
|
||||
public function setPageId(int $pageId): static |
||||
{ |
||||
$this->pageId = $pageId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getUserId(): ?int |
||||
{ |
||||
return $this->userId; |
||||
} |
||||
|
||||
public function setUserId(int $userId): static |
||||
{ |
||||
$this->userId = $userId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getAdded(): ?int |
||||
{ |
||||
return $this->added; |
||||
} |
||||
|
||||
public function setAdded(int $added): static |
||||
{ |
||||
$this->added = $added; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getLocale(): ?string |
||||
{ |
||||
return $this->locale; |
||||
} |
||||
|
||||
public function setLocale(string $locale): static |
||||
{ |
||||
$this->locale = $locale; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getValue(): ?string |
||||
{ |
||||
return $this->value; |
||||
} |
||||
|
||||
public function setValue(string $value): static |
||||
{ |
||||
$this->value = $value; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function isApproved(): ?bool |
||||
{ |
||||
return $this->approved; |
||||
} |
||||
|
||||
public function setApproved(bool $approved): static |
||||
{ |
||||
$this->approved = $approved; |
||||
|
||||
return $this; |
||||
} |
||||
} |
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
<?php |
||||
|
||||
namespace App\Entity; |
||||
|
||||
use App\Repository\PageTorrentsRepository; |
||||
use Doctrine\DBAL\Types\Types; |
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
#[ORM\Entity(repositoryClass: PageTorrentsRepository::class)] |
||||
class PageTorrents |
||||
{ |
||||
#[ORM\Id] |
||||
#[ORM\GeneratedValue] |
||||
#[ORM\Column] |
||||
private ?int $id = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $pageId = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $userId = null; |
||||
|
||||
#[ORM\Column(type: Types::ARRAY)] |
||||
private array $torrentsId = []; |
||||
|
||||
#[ORM\Column] |
||||
private ?int $added = null; |
||||
|
||||
#[ORM\Column] |
||||
private ?bool $approved = null; |
||||
|
||||
public function getId(): ?int |
||||
{ |
||||
return $this->id; |
||||
} |
||||
|
||||
public function setId(string $id): static |
||||
{ |
||||
$this->id = $id; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getPageId(): ?int |
||||
{ |
||||
return $this->pageId; |
||||
} |
||||
|
||||
public function setPageId(int $pageId): static |
||||
{ |
||||
$this->pageId = $pageId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getUserId(): ?int |
||||
{ |
||||
return $this->userId; |
||||
} |
||||
|
||||
public function setUserId(int $userId): static |
||||
{ |
||||
$this->userId = $userId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getTorrentsId(): array |
||||
{ |
||||
return $this->torrentsId; |
||||
} |
||||
|
||||
public function setTorrentsId(array $torrentsId): static |
||||
{ |
||||
$this->torrentsId = $torrentsId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getAdded(): ?int |
||||
{ |
||||
return $this->added; |
||||
} |
||||
|
||||
public function setAdded(int $added): static |
||||
{ |
||||
$this->added = $added; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function isApproved(): ?bool |
||||
{ |
||||
return $this->approved; |
||||
} |
||||
|
||||
public function setApproved(bool $approved): static |
||||
{ |
||||
$this->approved = $approved; |
||||
|
||||
return $this; |
||||
} |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
<?php |
||||
|
||||
namespace App\Repository; |
||||
|
||||
use App\Entity\Activity; |
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||||
use Doctrine\Persistence\ManagerRegistry; |
||||
|
||||
/** |
||||
* @extends ServiceEntityRepository<Activity> |
||||
* |
||||
* @method Activity|null find($id, $lockMode = null, $lockVersion = null) |
||||
* @method Activity|null findOneBy(array $criteria, array $orderBy = null) |
||||
* @method Activity[] findAll() |
||||
* @method Activity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
||||
*/ |
||||
class ActivityRepository extends ServiceEntityRepository |
||||
{ |
||||
public function __construct(ManagerRegistry $registry) |
||||
{ |
||||
parent::__construct($registry, Activity::class); |
||||
} |
||||
|
||||
public function findLast(int $start = 0, int $limit = 10): array |
||||
{ |
||||
return $this->createQueryBuilder('a') |
||||
->orderBy('a.id', 'DESC') // same to a.added |
||||
->setFirstResult($start) |
||||
->setMaxResults($limit) |
||||
->getQuery() |
||||
->getResult() |
||||
; |
||||
} |
||||
|
||||
public function findLastByApprovedField(bool $approved, int $start = 0, int $limit = 10): array |
||||
{ |
||||
return $this->createQueryBuilder('a') |
||||
->orderBy('a.id', 'DESC') // same to a.added |
||||
->where('a.approved = :approved') |
||||
->setParameter('approved', $approved) |
||||
->setFirstResult($start) |
||||
->setMaxResults($limit) |
||||
->getQuery() |
||||
->getResult() |
||||
; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
<?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); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
<?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); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
<?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); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
<?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); |
||||
} |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
<?php |
||||
|
||||
namespace App\Service; |
||||
|
||||
use App\Entity\Activity; |
||||
use App\Repository\ActivityRepository; |
||||
use Doctrine\ORM\EntityManagerInterface; |
||||
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
||||
|
||||
class ActivityService |
||||
{ |
||||
private EntityManagerInterface $entityManager; |
||||
private ActivityRepository $activityRepository; |
||||
private ParameterBagInterface $parameterBagInterface; |
||||
|
||||
public function __construct( |
||||
EntityManagerInterface $entityManager, |
||||
ParameterBagInterface $parameterBagInterface |
||||
) |
||||
{ |
||||
$this->entityManager = $entityManager; |
||||
$this->activityRepository = $entityManager->getRepository(Activity::class); |
||||
$this->parameterBagInterface = $parameterBagInterface; |
||||
} |
||||
|
||||
public function addEvent(int $userId, string $event, array $data): ?Activity |
||||
{ |
||||
$activity = new Activity(); |
||||
|
||||
$activity->setEvent($event); |
||||
$activity->setUserId($userId); |
||||
$activity->setApproved($approved); |
||||
$activity->setAdded(time()); |
||||
|
||||
$this->entityManager->persist($activity); |
||||
$this->entityManager->flush(); |
||||
|
||||
return $activity; |
||||
} |
||||
|
||||
public function findLast(bool $moderator): ?array |
||||
{ |
||||
if ($moderator) |
||||
{ |
||||
return $this->activityRepository->findLast(); |
||||
} |
||||
|
||||
else |
||||
{ |
||||
return $this->activityRepository->findLastByApprovedField(true); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
{% extends 'default/layout.html.twig' %} |
||||
{% block title %}{{ title }} - {{ name }}{% endblock %} |
Loading…
Reference in new issue