-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78c5f9b
commit 7c9f49c
Showing
4 changed files
with
64 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Service\ModListUpdateService; | ||
|
||
use App\Entity\ModGroup\ModGroupInterface; | ||
use App\Entity\ModList\ModList; | ||
use App\Entity\User\UserInterface; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\Security\Core\Security; | ||
|
||
class ModListUpdateService implements ModListUpdateServiceInterface | ||
{ | ||
public function __construct( | ||
private EntityManagerInterface $entityManager, | ||
private Security $security, | ||
) { | ||
} | ||
|
||
public function updateModListsAssociatedWithModGroup(ModGroupInterface $modGroup): void | ||
{ | ||
$currentUser = $this->security->getUser(); | ||
if (!$currentUser instanceof UserInterface) { | ||
return; | ||
} | ||
|
||
$queryBuilder = $this->entityManager->createQueryBuilder(); | ||
$expr = $queryBuilder->expr(); | ||
|
||
$queryBuilder | ||
->update(ModList::class, 'ml') | ||
|
||
->set('ml.lastUpdatedAt', ':dateTime') | ||
->setParameter('dateTime', new \DateTimeImmutable()) | ||
|
||
->set('ml.lastUpdatedBy', ':user') | ||
->setParameter('user', $currentUser) | ||
|
||
->andWhere($expr->isMemberOf(':modGroupId', 'ml.modGroups')) | ||
->setParameter('modGroupId', $modGroup->getId()->toString()) | ||
; | ||
|
||
$queryBuilder->getQuery()->execute(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Service/ModListUpdateService/ModListUpdateServiceInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Service\ModListUpdateService; | ||
|
||
use App\Entity\ModGroup\ModGroupInterface; | ||
|
||
interface ModListUpdateServiceInterface | ||
{ | ||
public function updateModListsAssociatedWithModGroup(ModGroupInterface $modGroup): void; | ||
} |