mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
update page form dependencies #19
This commit is contained in:
parent
8df29ef605
commit
c0cc029350
22 changed files with 1049 additions and 102 deletions
54
src/Service/ActivityService.php
Normal file
54
src/Service/ActivityService.php
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue