diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 414ae47aa..f6f9d55f6 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -507,12 +507,7 @@ class User implements UserInterface, \Stringable public function setMainScope(?Scope $mainScope): User { - $currentScopeUnchanged = array_filter( - $this->scopeHistories->toArray(), - fn($row) => $row->getEndDate() === null && $row->getScope() === $mainScope - ); - - if (count($currentScopeUnchanged) > 0) { + if ($mainScope === $this->getMainScope()) { return $this; } @@ -572,12 +567,7 @@ class User implements UserInterface, \Stringable public function setUserJob(?UserJob $userJob): User { - $currentJobUnchanged = array_filter( - $this->jobHistories->toArray(), - fn($row) => $row->getEndDate() === null && $row->getJob() === $userJob - ); - - if (count($currentJobUnchanged) > 0) { + if ($userJob === $this->getUserJob()) { return $this; } diff --git a/src/Bundle/ChillMainBundle/Repository/User/UserJobHistoryRepository.php b/src/Bundle/ChillMainBundle/Repository/User/UserJobHistoryRepository.php index a66575e3b..39186241f 100644 --- a/src/Bundle/ChillMainBundle/Repository/User/UserJobHistoryRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/User/UserJobHistoryRepository.php @@ -17,35 +17,13 @@ use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMException; use Doctrine\Persistence\ManagerRegistry; +/** + * @extends ServiceEntityRepository + */ class UserJobHistoryRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, UserJobHistory::class); } - - /** - * @throws ORMException - * @throws OptimisticLockException - */ - public function add(UserJobHistory $entity, bool $flush = true): void - { - $this->_em->persist($entity); - if ($flush) { - $this->_em->flush(); - } - } - - /** - * @throws ORMException - * @throws OptimisticLockException - */ - public function remove(UserJobHistory $entity, bool $flush = true): void - { - $this->_em->remove($entity); - if ($flush) { - $this->_em->flush(); - } - } - } diff --git a/src/Bundle/ChillMainBundle/Repository/User/UserScopeHistoryRepository.php b/src/Bundle/ChillMainBundle/Repository/User/UserScopeHistoryRepository.php index aa6738870..739e653c3 100644 --- a/src/Bundle/ChillMainBundle/Repository/User/UserScopeHistoryRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/User/UserScopeHistoryRepository.php @@ -17,35 +17,13 @@ use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMException; use Doctrine\Persistence\ManagerRegistry; +/** + * @extends ServiceEntityRepository + */ final class UserScopeHistoryRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, UserScopeHistory::class); } - - /** - * @throws ORMException - * @throws OptimisticLockException - */ - public function add(UserScopeHistory $entity, bool $flush = true): void - { - $this->_em->persist($entity); - if ($flush) { - $this->_em->flush(); - } - } - - /** - * @throws ORMException - * @throws OptimisticLockException - */ - public function remove(UserScopeHistory $entity, bool $flush = true): void - { - $this->_em->remove($entity); - if ($flush) { - $this->_em->flush(); - } - } - }