initial commit
This commit is contained in:
		@@ -6,8 +6,8 @@ use App\Entity\User;
 | 
				
			|||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
 | 
					use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
 | 
				
			||||||
use Doctrine\Persistence\ManagerRegistry;
 | 
					use Doctrine\Persistence\ManagerRegistry;
 | 
				
			||||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
 | 
					use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
 | 
				
			||||||
 | 
					use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
 | 
				
			||||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
 | 
					use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
 | 
				
			||||||
use Symfony\Component\Security\Core\User\UserInterface;
 | 
					 | 
				
			||||||
use function get_class;
 | 
					use function get_class;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -20,20 +20,40 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public function __construct(ManagerRegistry $registry)
 | 
					    public function __construct(ManagerRegistry $registry)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        parent::__construct($registry, User::class);
 | 
					        parent::__construct(registry: $registry, entityClass: User::class);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function add(User $entity, bool $flush = true): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->_em->persist(entity: $entity);
 | 
				
			||||||
 | 
					        if ($flush) {
 | 
				
			||||||
 | 
					            $this->_em->flush();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function remove(User $entity, bool $flush = true): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->_em->remove(entity: $entity);
 | 
				
			||||||
 | 
					        if ($flush) {
 | 
				
			||||||
 | 
					            $this->_em->flush();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Used to upgrade (rehash) the user's password automatically over time.
 | 
					     * Used to upgrade (rehash) the user's password automatically over time.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function upgradePassword(UserInterface $user, string $newHashedPassword): void
 | 
					    public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!$user instanceof User) {
 | 
					        if (!$user instanceof User) {
 | 
				
			||||||
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
 | 
					            throw new UnsupportedUserException(message: sprintf('Instances of "%s" are not supported.', get_class(object: $user)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $user->setPassword($newHashedPassword);
 | 
					        $user->setPassword(password: $newHashedPassword);
 | 
				
			||||||
        $this->_em->persist($user);
 | 
					        $this->_em->persist(entity: $user);
 | 
				
			||||||
        $this->_em->flush();
 | 
					        $this->_em->flush();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user