add new entities UserScopeHistory and UserJobHistory

This commit is contained in:
Mathieu Jaumotte 2023-09-12 15:55:08 +02:00
parent ef8ac6041a
commit d47e6c5ba1
4 changed files with 316 additions and 0 deletions

View File

@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Entity\User;
use App\Repository\UserJobHistoryRepository;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserJob;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_main_user_job_history")
* @ORM\Entity(repositoryClass=UserJobHistoryRepository::class)
*/
class UserJobHistory
{
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $endDate = null;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=UserJob::class)
*/
private ?UserJob $job = null;
/**
* @ORM\Column(type="datetime_immutable")
*/
private DateTimeImmutable $startDate;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private User $user;
public function getEndDate(): ?DateTimeImmutable
{
return $this->endDate;
}
public function getId(): ?int
{
return $this->id;
}
public function getJob(): ?UserJob
{
return $this->job;
}
public function getStartDate(): ?DateTimeImmutable
{
return $this->startDate;
}
public function getUser(): User
{
return $this->user;
}
public function setEndDate(?DateTimeImmutable $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function setJob(?UserJob $job): UserJobHistory
{
$this->job = $job;
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function setUser(User $user): UserJobHistory
{
$this->user = $user;
return $this;
}
}

View File

@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Entity\User;
use App\Repository\UserScopeHistoryRepository;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_main_user_scope_history")
* @ORM\Entity(repositoryClass=UserScopeHistoryRepository::class)
*/
class UserScopeHistory
{
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $endDate = null;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Scope::class)
*/
private ?Scope $scope = null;
/**
* @ORM\Column(type="datetime_immutable")
*/
private DateTimeImmutable $startDate;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private User $user;
public function getEndDate(): ?DateTimeImmutable
{
return $this->endDate;
}
public function getId(): ?int
{
return $this->id;
}
public function getScope(): ?Scope
{
return $this->scope;
}
public function getStartDate(): ?DateTimeImmutable
{
return $this->startDate;
}
public function getUser(): User
{
return $this->user;
}
public function setEndDate(?DateTimeImmutable $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function setScope(?Scope $scope): UserScopeHistory
{
$this->scope = $scope;
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function setUser(User $user): UserScopeHistory
{
$this->user = $user;
return $this;
}
}

View File

@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Repository\User;
use App\Entity\UserJobHistory;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;
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();
}
}
}

View File

@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Repository\User;
use App\Entity\UserScopeHistory;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;
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();
}
}
}