我正在尝试做自己的自定义用户提供程序,但我被困在 Symfony 教程的这一部分(创建用户提供程序)。
我需要对 $userdata 变量做什么?数据库连接?
我不知道我需要在这个地方做什么:
public function loadUserByUsername($username)
{
// here
// $userData = ...
if ($userData) {
//here too
//$password = ...
return new DomixBlogUser($username, $password, $salt, $roles)
} else {
throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
}
}
编辑#1
public function loadUserByUsername($username)
{
$userData = $this->_em->getRepository("DomixBlogBundle:User")->findOneBy(array('username' => $username));
var_dump($userData);
if ($userData) {
$salt = '54hg5g4hfjh4g5sdgf45gd4h84gjhdf54gf4g2f2gfdhggfdg';
$password = $userData->getPassword().'{'.$salt.'}';
return new DomixBlogUser($username, $password, $salt, $roles);
} else {
throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
}
}
那挺好的?