Skip to content

Commit f84971b

Browse files
committed
chore: upgrade to doctrine/orm 3
1 parent 4753519 commit f84971b

File tree

9 files changed

+157
-119
lines changed

9 files changed

+157
-119
lines changed

api/composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
"cweagans/composer-patches": "1.7.3",
1111
"doctrine/doctrine-bundle": "2.12.0",
1212
"doctrine/doctrine-migrations-bundle": "3.3.1",
13-
"doctrine/orm": "2.19.5",
13+
"doctrine/orm": "3.2.0",
1414
"exercise/htmlpurifier-bundle": "5.0",
1515
"friendsofsymfony/http-cache": "3.0.0",
1616
"friendsofsymfony/http-cache-bundle": "3.0.1",
17+
"gedmo/doctrine-extensions": "dev-main as 3.16",
1718
"google/recaptcha": "1.3.0",
1819
"guzzlehttp/guzzle": "7.8.1",
1920
"knpuniversity/oauth2-client-bundle": "2.18.1",
@@ -52,7 +53,7 @@
5253
},
5354
"require-dev": {
5455
"friendsofphp/php-cs-fixer": "3.58.1",
55-
"hautelook/alice-bundle": "2.13.0",
56+
"hautelook/alice-bundle": "2.14.0",
5657
"justinrainbow/json-schema": "5.2.13",
5758
"php-coveralls/php-coveralls": "2.7.0",
5859
"phpspec/prophecy-phpunit": "2.2",
@@ -156,4 +157,4 @@
156157
}
157158
}
158159
}
159-
}
160+
}

api/composer.lock

Lines changed: 62 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/src/HttpCache/PurgeHttpCacheListener.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(private readonly IriConverterInterface|LegacyIriConv
5050
*/
5151
public function preUpdate(PreUpdateEventArgs $eventArgs): void {
5252
$changeSet = $eventArgs->getEntityChangeSet();
53-
$objectManager = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();
53+
$objectManager = $eventArgs->getObjectManager();
5454
$associationMappings = $objectManager->getClassMetadata(ClassUtils::getClass($eventArgs->getObject()))->getAssociationMappings();
5555

5656
foreach ($changeSet as $key => $value) {
@@ -72,7 +72,12 @@ public function preUpdate(PreUpdateEventArgs $eventArgs): void {
7272
* Collects tags from inserted, updated and deleted entities, including relations.
7373
*/
7474
public function onFlush(OnFlushEventArgs $eventArgs): void {
75-
$em = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();
75+
$em = $eventArgs->getObjectManager();
76+
77+
if (!$em instanceof EntityManagerInterface) {
78+
return;
79+
}
80+
7681
$uow = $em->getUnitOfWork();
7782

7883
foreach ($uow->getScheduledEntityInsertions() as $entity) {
@@ -179,15 +184,7 @@ private function gatherRelationTags(EntityManagerInterface $em, object $entity):
179184
$associationMappings = $em->getClassMetadata(ClassUtils::getClass($entity))->getAssociationMappings();
180185

181186
foreach ($associationMappings as $property => $associationMapping) {
182-
// @phpstan-ignore-next-line
183-
if (class_exists(AssociationMapping::class) && $associationMapping instanceof AssociationMapping && ($associationMapping->targetEntity ?? null) && !$this->resourceClassResolver->isResourceClass($associationMapping->targetEntity)) {
184-
return;
185-
}
186-
187-
// @phpstan-ignore-next-line
188-
if (\is_array($associationMapping)
189-
&& \array_key_exists('targetEntity', $associationMapping)
190-
&& !$this->resourceClassResolver->isResourceClass($associationMapping['targetEntity'])) {
187+
if ($associationMapping instanceof AssociationMapping && ($associationMapping->targetEntity ?? null) && !$this->resourceClassResolver->isResourceClass($associationMapping->targetEntity)) {
191188
return;
192189
}
193190

api/src/Repository/UserRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string
3232
}
3333

3434
$user->password = $newHashedPassword;
35-
$this->_em->persist($user);
36-
$this->_em->flush();
35+
$this->getEntityManager()->persist($user);
36+
$this->getEntityManager()->flush();
3737
}
3838

3939
/**
4040
* @throws NonUniqueResultException
4141
* @throws NoResultException
4242
*/
4343
public function loadUserByIdentifier(string $identifier): ?User {
44-
$queryBuilder = $this->_em->createQueryBuilder();
44+
$queryBuilder = $this->getEntityManager()->createQueryBuilder();
4545
$queryBuilder->select('user');
4646
$queryBuilder->from(User::class, 'user');
4747
$queryBuilder->join('user.profile', 'profile');

0 commit comments

Comments
 (0)