Merge branch '4.4' into 5.0
* 4.4: Add missing annotation Fix merge
This commit is contained in:
commit
0370699cea
@ -51,7 +51,7 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
*/
|
*/
|
||||||
public function loadUserByUsername(string $username)
|
public function loadUserByUsername(string $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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class DoctrineTestHelper
|
|||||||
$symfonyFileLocator = class_exists(SymfonyFileLocator::class) ? SymfonyFileLocator::class : LegacySymfonyFileLocator::class;
|
$symfonyFileLocator = class_exists(SymfonyFileLocator::class) ? SymfonyFileLocator::class : LegacySymfonyFileLocator::class;
|
||||||
$driverChain = class_exists(MappingDriverChain::class) ? MappingDriverChain::class : LegacyMappingDriverChain::class;
|
$driverChain = class_exists(MappingDriverChain::class) ? MappingDriverChain::class : LegacyMappingDriverChain::class;
|
||||||
|
|
||||||
$driverChain = new MappingDriverChain();
|
$driverChain = new $driverChain();
|
||||||
$driverChain->addDriver(
|
$driverChain->addDriver(
|
||||||
new XmlDriver(
|
new XmlDriver(
|
||||||
new $symfonyFileLocator(
|
new $symfonyFileLocator(
|
||||||
|
@ -29,8 +29,10 @@ final class TestRepositoryFactory implements RepositoryFactory
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return ObjectRepository|LegacyObjectRepository
|
||||||
*/
|
*/
|
||||||
public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
|
public function getRepository(EntityManagerInterface $entityManager, $entityName)
|
||||||
{
|
{
|
||||||
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
|
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user