Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to doctrine/orm 3 #5365

Draft
wants to merge 4 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"cweagans/composer-patches": "1.7.3",
"doctrine/doctrine-bundle": "2.12.0",
"doctrine/doctrine-migrations-bundle": "3.3.1",
"doctrine/orm": "2.19.5",
"doctrine/orm": "3.2.0",
"exercise/htmlpurifier-bundle": "5.0",
"friendsofsymfony/http-cache": "3.0.0",
"friendsofsymfony/http-cache-bundle": "3.0.1",
"gedmo/doctrine-extensions": "dev-main as 3.16",
"google/recaptcha": "1.3.0",
"guzzlehttp/guzzle": "7.8.1",
"knpuniversity/oauth2-client-bundle": "2.18.1",
Expand Down Expand Up @@ -52,7 +53,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.58.1",
"hautelook/alice-bundle": "2.13.0",
"hautelook/alice-bundle": "2.14.0",
"justinrainbow/json-schema": "5.2.13",
"php-coveralls/php-coveralls": "2.7.0",
"phpspec/prophecy-phpunit": "2.2",
Expand Down Expand Up @@ -156,4 +157,4 @@
}
}
}
}
}
125 changes: 62 additions & 63 deletions api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions api/src/HttpCache/PurgeHttpCacheListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(private readonly IriConverterInterface|LegacyIriConv
*/
public function preUpdate(PreUpdateEventArgs $eventArgs): void {
$changeSet = $eventArgs->getEntityChangeSet();
$objectManager = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();
$objectManager = $eventArgs->getObjectManager();
$associationMappings = $objectManager->getClassMetadata(ClassUtils::getClass($eventArgs->getObject()))->getAssociationMappings();

foreach ($changeSet as $key => $value) {
Expand All @@ -72,7 +72,12 @@ public function preUpdate(PreUpdateEventArgs $eventArgs): void {
* Collects tags from inserted, updated and deleted entities, including relations.
*/
public function onFlush(OnFlushEventArgs $eventArgs): void {
$em = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();
$em = $eventArgs->getObjectManager();

if (!$em instanceof EntityManagerInterface) {
return;
}

$uow = $em->getUnitOfWork();

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

foreach ($associationMappings as $property => $associationMapping) {
// @phpstan-ignore-next-line
if (class_exists(AssociationMapping::class) && $associationMapping instanceof AssociationMapping && ($associationMapping->targetEntity ?? null) && !$this->resourceClassResolver->isResourceClass($associationMapping->targetEntity)) {
return;
}

// @phpstan-ignore-next-line
if (\is_array($associationMapping)
&& \array_key_exists('targetEntity', $associationMapping)
&& !$this->resourceClassResolver->isResourceClass($associationMapping['targetEntity'])) {
if ($associationMapping instanceof AssociationMapping && ($associationMapping->targetEntity ?? null) && !$this->resourceClassResolver->isResourceClass($associationMapping->targetEntity)) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions api/src/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string
}

$user->password = $newHashedPassword;
$this->_em->persist($user);
$this->_em->flush();
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();
}

/**
* @throws NonUniqueResultException
* @throws NoResultException
*/
public function loadUserByIdentifier(string $identifier): ?User {
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder = $this->getEntityManager()->createQueryBuilder();
$queryBuilder->select('user');
$queryBuilder->from(User::class, 'user');
$queryBuilder->join('user.profile', 'profile');
Expand Down
Loading
Loading