8000 Merge branch '4.3' into 4.4 · symfony/symfony@93b2f9e · GitHub
[go: up one dir, main page]

Skip to content

Commit 93b2f9e

Browse files
Merge branch '4.3' into 4.4
* 4.3: Fix merge
2 parents a31119b + 7d88be8 commit 93b2f9e

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7< 10000 /div>lines changed

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private function getMetadata(string $class): ?ClassMetadata
202202
{
203203
try {
204204
return $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class);
205-
} catch (MappingException | OrmMappingException $exception) {
205+
} catch (MappingException | OrmMappingException | LegacyMappingException $exception) {
206206
return null;
207207
}
208208
}

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct($registry, string $classOrAlias, string $property =
5151
*/
5252
public function loadUserByUsername($username)
5353
{
54-
$repository = $this->registry->getManager($this->managerName)->getRepository($this->classOrAlias);
54+
$repository = $this->getRepository();
5555
if (null !== $this->property) {
5656
$user = $repository->findOneBy([$this->property => $username]);
5757
} else {
@@ -79,15 +79,15 @@ public function refreshUser(UserInterface $user)
7979
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
8080
}
8181

82-
$repository = $this->registry->getManager($this->managerName)->getRepository($this->classOrAlias);
82+
$repository = $this->getRepository();
8383
if ($repository instanceof UserProviderInterface) {
8484
$refreshedUser = $repository->refreshUser($user);
8585
} else {
8686
// The user must be reloaded via the primary key as all other data
8787
// might have changed without proper persistence in the database.
8888
// That's the case when the user has been changed by a form with
8989
// validation errors.
90-
if (!$id = $this->registry->getManager($this->managerName)->getClassMetadata($this->classOrAlias)->getIdentifierValues($user)) {
90+
if (!$id = $this->getClassMetadata()->getIdentifierValues($user)) {
9191
throw new \InvalidArgumentException('You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine.');
9292
}
9393

@@ -118,24 +118,39 @@ public function upgradePassword(UserInterface $user, string $newEncodedPassword)
118118
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
119119
}
120120

121-
$repository = $this->registry->getManager($this->managerName)->getRepository($this->classOrAlias);
121+
$repository = $this->getRepository();
122122
if ($repository instanceof PasswordUpgraderInterface) {
123123
$repository->upgradePassword($user, $newEncodedPassword);
124124
}
125125
}
126126

127+
private function getObjectManager()
128+
{
129+
return $this->registry->getManager($this->managerName);
130+
}
131+
132+
private function getRepository()
133+
{
134+
return $this->getObjectManager()->getRepository($this->classOrAlias);
135+
}
136+
127137
private function getClass(): string
128138
{
129139
if (null === $this->class) {
130140
$class = $this->classOrAlias;
131141

132142
if (false !== strpos($class, ':')) {
133-
$class = $this->registry->getManager($this->managerName)->getClassMetadata($this->classOrAlias)->getName();
143+
$class = $this->getClassMetadata()->getName();
134144
}
135145

136146
$this->class = $class;
137147
}
138148

139149
return $this->class;
140150
}
151+
152+
private function getClassMetadata()
153+
{
154+
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
155+
}
141156
}

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public function testLoaderWithoutIdReaderCanBeOptimized()
408408
})
409409
;
410410

411-
$this->om = $this->createMock(ObjectManager::class);
411+
$this->om = $this->createMock(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class);
412412
$this->om->expects($this->once())
413413
->method('getClassMetadata')
414414
->with(SingleIntIdEntity::class)

0 commit comments

Comments
 (0)
0