mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
improve check in setters and add types in repositories
This commit is contained in:
parent
e6e42777d7
commit
949c5424f0
@ -507,12 +507,7 @@ class User implements UserInterface, \Stringable
|
|||||||
|
|
||||||
public function setMainScope(?Scope $mainScope): User
|
public function setMainScope(?Scope $mainScope): User
|
||||||
{
|
{
|
||||||
$currentScopeUnchanged = array_filter(
|
if ($mainScope === $this->getMainScope()) {
|
||||||
$this->scopeHistories->toArray(),
|
|
||||||
fn($row) => $row->getEndDate() === null && $row->getScope() === $mainScope
|
|
||||||
);
|
|
||||||
|
|
||||||
if (count($currentScopeUnchanged) > 0) {
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,12 +567,7 @@ class User implements UserInterface, \Stringable
|
|||||||
|
|
||||||
public function setUserJob(?UserJob $userJob): User
|
public function setUserJob(?UserJob $userJob): User
|
||||||
{
|
{
|
||||||
$currentJobUnchanged = array_filter(
|
if ($userJob === $this->getUserJob()) {
|
||||||
$this->jobHistories->toArray(),
|
|
||||||
fn($row) => $row->getEndDate() === null && $row->getJob() === $userJob
|
|
||||||
);
|
|
||||||
|
|
||||||
if (count($currentJobUnchanged) > 0) {
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,35 +17,13 @@ use Doctrine\ORM\OptimisticLockException;
|
|||||||
use Doctrine\ORM\ORMException;
|
use Doctrine\ORM\ORMException;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<UserJobHistory>
|
||||||
|
*/
|
||||||
class UserJobHistoryRepository extends ServiceEntityRepository
|
class UserJobHistoryRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
{
|
{
|
||||||
parent::__construct($registry, UserJobHistory::class);
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,35 +17,13 @@ use Doctrine\ORM\OptimisticLockException;
|
|||||||
use Doctrine\ORM\ORMException;
|
use Doctrine\ORM\ORMException;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<UserScopeHistory>
|
||||||
|
*/
|
||||||
final class UserScopeHistoryRepository extends ServiceEntityRepository
|
final class UserScopeHistoryRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
{
|
{
|
||||||
parent::__construct($registry, UserScopeHistory::class);
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user