Merge branch '4.3' into 4.4
* 4.3: Fix merge
This commit is contained in:
commit
93b2f9ef6f
@ -202,7 +202,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class);
|
return $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class);
|
||||||
} catch (MappingException | OrmMappingException $exception) {
|
} catch (MappingException | OrmMappingException | LegacyMappingException $exception) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
*/
|
*/
|
||||||
public function loadUserByUsername($username)
|
public function loadUserByUsername($username)
|
||||||
{
|
{
|
||||||
$repository = $this->registry->getManager($this->managerName)->getRepository($this->classOrAlias);
|
$repository = $this->getRepository();
|
||||||
if (null !== $this->property) {
|
if (null !== $this->property) {
|
||||||
$user = $repository->findOneBy([$this->property => $username]);
|
$user = $repository->findOneBy([$this->property => $username]);
|
||||||
} else {
|
} else {
|
||||||
@ -79,7 +79,7 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$repository = $this->registry->getManager($this->managerName)->getRepository($this->classOrAlias);
|
$repository = $this->getRepository();
|
||||||
if ($repository instanceof UserProviderInterface) {
|
if ($repository instanceof UserProviderInterface) {
|
||||||
$refreshedUser = $repository->refreshUser($user);
|
$refreshedUser = $repository->refreshUser($user);
|
||||||
} else {
|
} else {
|
||||||
@ -87,7 +87,7 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
// might have changed without proper persistence in the database.
|
// might have changed without proper persistence in the database.
|
||||||
// That's the case when the user has been changed by a form with
|
// That's the case when the user has been changed by a form with
|
||||||
// validation errors.
|
// validation errors.
|
||||||
if (!$id = $this->registry->getManager($this->managerName)->getClassMetadata($this->classOrAlias)->getIdentifierValues($user)) {
|
if (!$id = $this->getClassMetadata()->getIdentifierValues($user)) {
|
||||||
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.');
|
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.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,19 +118,29 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$repository = $this->registry->getManager($this->managerName)->getRepository($this->classOrAlias);
|
$repository = $this->getRepository();
|
||||||
if ($repository instanceof PasswordUpgraderInterface) {
|
if ($repository instanceof PasswordUpgraderInterface) {
|
||||||
$repository->upgradePassword($user, $newEncodedPassword);
|
$repository->upgradePassword($user, $newEncodedPassword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getObjectManager()
|
||||||
|
{
|
||||||
|
return $this->registry->getManager($this->managerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getRepository()
|
||||||
|
{
|
||||||
|
return $this->getObjectManager()->getRepository($this->classOrAlias);
|
||||||
|
}
|
||||||
|
|
||||||
private function getClass(): string
|
private function getClass(): string
|
||||||
{
|
{
|
||||||
if (null === $this->class) {
|
if (null === $this->class) {
|
||||||
$class = $this->classOrAlias;
|
$class = $this->classOrAlias;
|
||||||
|
|
||||||
if (false !== strpos($class, ':')) {
|
if (false !== strpos($class, ':')) {
|
||||||
$class = $this->registry->getManager($this->managerName)->getClassMetadata($this->classOrAlias)->getName();
|
$class = $this->getClassMetadata()->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->class = $class;
|
$this->class = $class;
|
||||||
@ -138,4 +148,9 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
|
|
||||||
return $this->class;
|
return $this->class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getClassMetadata()
|
||||||
|
{
|
||||||
|
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
|||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->om = $this->createMock(ObjectManager::class);
|
$this->om = $this->createMock(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class);
|
||||||
$this->om->expects($this->once())
|
$this->om->expects($this->once())
|
||||||
->method('getClassMetadata')
|
->method('getClassMetadata')
|
||||||
->with(SingleIntIdEntity::class)
|
->with(SingleIntIdEntity::class)
|
||||||
|
Reference in New Issue
Block a user