|
|
@@ -5,6 +5,7 @@ namespace Lc\SovBundle\Builder\User; |
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
use Lc\SovBundle\Doctrine\EntityInterface; |
|
|
|
use Lc\SovBundle\Doctrine\Extension\BlameableInterface; |
|
|
|
use Lc\SovBundle\Factory\User\UserFactory; |
|
|
|
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; |
|
|
|
use Lc\SovBundle\Model\User\UserInterface; |
|
|
|
use Lc\SovBundle\Repository\User\UserStore; |
|
|
@@ -15,11 +16,29 @@ class UserBuilder |
|
|
|
protected EntityManagerInterface $entityManager; |
|
|
|
protected UserStore $userStore; |
|
|
|
protected UserSolver $userSolver; |
|
|
|
public function __construct(EntityManagerInterface $entityManager, UserStore $userStore, UserSolver $userSolver) |
|
|
|
protected UserFactory $userFactory; |
|
|
|
|
|
|
|
public function __construct(EntityManagerInterface $entityManager, UserStore $userStore, UserSolver $userSolver, UserFactory $userFactory) |
|
|
|
{ |
|
|
|
$this->entityManager = $entityManager; |
|
|
|
$this->userStore = $userStore; |
|
|
|
$this->userSolver = $userSolver; |
|
|
|
$this->userFactory = $userFactory; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function create( string $email, string $password, array $roles=[]) |
|
|
|
{ |
|
|
|
$user = $this->userFactory->create(); |
|
|
|
$user->setEmail($email); |
|
|
|
$user->setPassword($password); |
|
|
|
|
|
|
|
$user->setRoles($roles); |
|
|
|
$this->entityManager->create($user); |
|
|
|
$this->entityManager->flush(); |
|
|
|
|
|
|
|
return $user; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public function setNewsletter(UserInterface $user, NewsletterInterface $newsletter, bool $subscribeNewsletter): void |
|
|
@@ -41,6 +60,7 @@ class UserBuilder |
|
|
|
|
|
|
|
return $entity; |
|
|
|
} |
|
|
|
|
|
|
|
public function initBlameableUpdatedSystem(EntityInterface $entity) |
|
|
|
{ |
|
|
|
$userSystem = $this->userStore->getOneByDevAlias('system'); |