34 lines
776 B
PHP
34 lines
776 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Repository;
|
||
|
|
||
|
use App\Entity\User;
|
||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||
|
use Doctrine\Persistence\ManagerRegistry;
|
||
|
|
||
|
class UserRepository extends ServiceEntityRepository
|
||
|
{
|
||
|
public function __construct(ManagerRegistry $registry)
|
||
|
{
|
||
|
parent::__construct($registry, User::class);
|
||
|
}
|
||
|
|
||
|
public function add(User $entity, bool $flush = false): void
|
||
|
{
|
||
|
$this->getEntityManager()->persist($entity);
|
||
|
|
||
|
if ($flush) {
|
||
|
$this->getEntityManager()->flush();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function remove(User $entity, bool $flush = false): void
|
||
|
{
|
||
|
$this->getEntityManager()->remove($entity);
|
||
|
|
||
|
if ($flush) {
|
||
|
$this->getEntityManager()->flush();
|
||
|
}
|
||
|
}
|
||
|
}
|