Newscoop\Entity\User::setPassword PHP Method

setPassword() public method

Set password
public setPassword ( string $password ) : Newscoop\Entity\User
$password string
return Newscoop\Entity\User
    public function setPassword($password)
    {
        $salt = $this->generateRandomString();
        $this->password = implode(self::HASH_SEP, array(self::HASH_ALGO, $salt, hash(self::HASH_ALGO, $salt . $password)));
        return $this;
    }

Usage Example

 public function setUp()
 {
     parent::setUp('Newscoop\\Entity\\User', 'Newscoop\\Entity\\Acl\\Role');
     $this->service = new DoctrineAuthService($this->em);
     $this->user = new User();
     $this->user->setEmail(self::EMAIL);
     $this->user->setUsername(self::USERNAME);
     $this->user->setPassword(self::PASSWORD);
     $this->em->persist($this->user);
     $this->em->flush();
 }
All Usage Examples Of Newscoop\Entity\User::setPassword