"<p>In this video we are going to add user entity using Security bundle so we can add JWT Authentication after that to our Apis.</p> <p>Security bundle : <a href="https://symfony.com/doc/current/security.html">Documentation</a></p> <p>UserDataPersister : </p> <pre> <code><?php namespace App\DataPersister; use ApiPlatform\Core\DataPersister\DataPersisterInterface; use App\Entity\User; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; class UserDataPersister implements DataPersisterInterface { private $entityManager; private $userPasswordEncoder; public function __construct(EntityManagerInterface $entityManager, UserPasswordEncoderInterface $userPasswordEncoder) { $this->entityManager = $entityManager; $this->userPasswordEncoder = $userPasswordEncoder; } public function supports($data):bool { return $data instanceof User; } /** * @param User $data */ public function persist($data) { if ($data->getPlainPassword()) { $data->setPassword( $this->userPasswordEncoder->encodePassword($data, $data->getPlainPassword()) ); $data->eraseCredentials(); } $this->entityManager->persist($data); $this->entityManager->flush(); } public function remove($data) { $this->entityManager->remove($data); $this->entityManager->flush(); } }</code></pre> <p> </p>"