Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public function __construct(
) {
}

public function loadUserByIdentifier(string $identifier): UserInterface
/**
* @param ?array $attributes
*/
public function loadUserByIdentifier(string $identifier/* , ?array $attributes = null */): UserInterface
{
$repository = $this->getRepository();
if (null !== $this->property) {
Expand All @@ -57,7 +60,11 @@ public function loadUserByIdentifier(string $identifier): UserInterface
throw new \InvalidArgumentException(\sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_debug_type($repository)));
}

$user = $repository->loadUserByIdentifier($identifier);
if (null === $attributes = \func_num_args() > 1 ? func_get_arg(1) : null) {
$user = $repository->loadUserByIdentifier($identifier);
} else {
$user = $repository->loadUserByIdentifier($identifier, $attributes);
}
}

if (null === $user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ public function testLoadUserByIdentifierShouldLoadUserWhenProperInterfaceProvide
$provider->loadUserByIdentifier('name');
}

public function testLoadUserByIdentifierShouldPassAttributesToTheUserLoader()
{
$repository = $this->createMock(UserLoaderRepository::class);
$repository->expects($this->once())
->method('loadUserByIdentifier')
->with('name', ['foo' => 'bar'])
->willReturn(
$this->createMock(UserInterface::class)
);

$provider = new EntityUserProvider(
$this->getManager($this->getObjectManager($repository)),
'Symfony\Bridge\Doctrine\Tests\Fixtures\User'
);

$provider->loadUserByIdentifier('name', ['foo' => 'bar']);
}

public function testLoadUserByIdentifierShouldDeclineInvalidInterface()
{
$repository = $this->createMock(ObjectRepository::class);
Expand Down
Loading