-
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.
Fix issue with mods lost on update - master (#286)
This will: - fix case in which Mods were unassigned from Mod Group on update This version is for master branch
- Loading branch information
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; | ||
} |