mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-25 08:05:00 +00:00
This update includes the implementation of methods to add and retrieve addressee history in the Ticket entity, a handler for addressee setting command, denormalizer for transforming request data to SetAddresseesCommand, and corresponding tests. Additionally, it adds a SetAddresseesController for handling addressee related requests and updates the API specifications.
95 lines
2.6 KiB
PHP
95 lines
2.6 KiB
PHP
<?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\TicketBundle\Entity;
|
|
|
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
|
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
|
use Chill\MainBundle\Entity\User;
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
|
|
#[ORM\Entity]
|
|
#[ORM\Table(name: 'person_history', schema: 'chill_ticket')]
|
|
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['ticket_person_history' => PersonHistory::class])]
|
|
class PersonHistory implements TrackCreationInterface
|
|
{
|
|
use TrackCreationTrait;
|
|
|
|
#[ORM\Id]
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false)]
|
|
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
|
#[Serializer\Groups(['read'])]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true, options: ['default' => null])]
|
|
#[Serializer\Groups(['read'])]
|
|
private ?\DateTimeImmutable $endDate = null;
|
|
|
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
|
#[ORM\JoinColumn(nullable: true)]
|
|
#[Serializer\Groups(['read'])]
|
|
private ?User $removedBy = null;
|
|
|
|
public function __construct(
|
|
#[ORM\ManyToOne(targetEntity: Person::class, fetch: 'EAGER')]
|
|
#[Serializer\Groups(['read'])]
|
|
private Person $person,
|
|
#[ORM\ManyToOne(targetEntity: Ticket::class)]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private Ticket $ticket,
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)]
|
|
#[Serializer\Groups(['read'])]
|
|
private \DateTimeImmutable $startDate,
|
|
) {
|
|
// keep ticket instance in sync with this
|
|
$this->ticket->addPersonHistory($this);
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getPerson(): Person
|
|
{
|
|
return $this->person;
|
|
}
|
|
|
|
public function getEndDate(): ?\DateTimeImmutable
|
|
{
|
|
return $this->endDate;
|
|
}
|
|
|
|
public function getTicket(): Ticket
|
|
{
|
|
return $this->ticket;
|
|
}
|
|
|
|
public function getStartDate(): \DateTimeImmutable
|
|
{
|
|
return $this->startDate;
|
|
}
|
|
|
|
public function getRemovedBy(): ?User
|
|
{
|
|
return $this->removedBy;
|
|
}
|
|
|
|
public function setEndDate(?\DateTimeImmutable $endDate): self
|
|
{
|
|
$this->endDate = $endDate;
|
|
|
|
return $this;
|
|
}
|
|
}
|