Skip to content

Commit

Permalink
Merge pull request #362 from Maxime-p/Deprecated-PasswordEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire authored Dec 17, 2021
2 parents 848ed19 + 874eb87 commit de0b63c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Resources/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ class. No problem! Your fixtures class is a service, so you can use normal depen
injection::

// src/DataFixtures/AppFixtures.php
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;

class AppFixtures extends Fixture
{
private $encoder;
private UserPasswordHasherInterface $hasher;

public function __construct(UserPasswordEncoderInterface $encoder)
public function __construct(UserPasswordHasherInterface $hasher)
{
$this->encoder = $encoder;
$this->hasher = $hasher;
}

// ...
Expand All @@ -125,7 +125,7 @@ injection::
$user = new User();
$user->setUsername('admin');

$password = $this->encoder->encodePassword($user, 'pass_1234');
$password = $this->hasher->hashPassword($user, 'pass_1234');
$user->setPassword($password);

$manager->persist($user);
Expand Down

0 comments on commit de0b63c

Please sign in to comment.