8000 Merge branch '5.0' · symfony/symfony@a8b6ba3 · GitHub
[go: up one dir, main page]

Skip to content

Commit a8b6ba3

Browse files
Merge branch '5.0'
* 5.0: Add missing annotation Fix merge
2 parents b94f9e5 + 0370699 commit a8b6ba3

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

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(string $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/Test/DoctrineTestHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static function createTestConfigurationWithXmlLoader()
7979
$symfonyFileLocator = class_exists(SymfonyFileLocator::class) ? SymfonyFileLocator::class : LegacySymfonyFileLocator::class;
8080
$driverChain = class_exists(MappingDriverChain::class) ? MappingDriverChain::class : LegacyMappingDriverChain::class;
8181

82-
$driverChain = new MappingDriverChain();
82+
$driverChain = new $driverChain();
8383
$driverChain->addDriver(
8484
new XmlDriver(
8585
new $symfonyFileLocator(

src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ final class TestRepositoryFactory implements RepositoryFactory
2929

3030
/**
3131
* {@inheritdoc}
32+
*
33+
* @return ObjectRepository|LegacyObjectRepository
3234
*/
33-
public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
35+
public function getRepository(EntityManagerInterface $entityManager, $entityName)
3436
{
3537
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
3638

0 commit comments

Comments
 (0)
0