for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
//----------------------------------------------------------------------
//
// Copyright (C) 2017 Artem Rodygin
// You should have received a copy of the MIT License along with
// this file. If not, see <http://opensource.org/licenses/MIT>.
namespace Pignus\Provider;
use Pignus\Model\UserRepositoryInterface;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
/**
* Abstract provider to load users from the database.
*/
abstract class AbstractUserProvider implements UserProviderInterface
{
protected $repository;
* Dependency Injection constructor.
*
* @param UserRepositoryInterface $repository
public function __construct(UserRepositoryInterface $repository)
$this->repository = $repository;
}
* {@inheritdoc}
public function loadUserByUsername($username)
$user = $this->repository->findOneByUsername($username);
if ($user === null) {
throw new UsernameNotFoundException();
return $user;
public function refreshUser(UserInterface $user)
if (!$this->supportsClass(get_class($user))) {
throw new UnsupportedUserException();
$user = $this->repository->findOneByUsername($user->getUsername());