mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
264 lines
7.2 KiB
PHP
264 lines
7.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
|
|
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
|
use Chill\MainBundle\Entity\User;
|
|
use DateTimeInterface;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use RuntimeException;
|
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table("chill_person_accompanying_period_work_evaluation_document")
|
|
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
|
* "accompanying_period_work_evaluation_document": AccompanyingPeriodWorkEvaluationDocument::class
|
|
* })
|
|
*/
|
|
class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
|
|
{
|
|
/**
|
|
* @ORM\ManyToOne(
|
|
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
|
* inversedBy="documents"
|
|
* )
|
|
*/
|
|
private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation = null;
|
|
|
|
/**
|
|
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*/
|
|
private ?\DateTimeImmutable $createdAt = null;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(
|
|
* targetEntity=User::class
|
|
* )
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*/
|
|
private ?User $createdBy = null;
|
|
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
*
|
|
* @internal the default name exceeds 64 characters, we must set manually:
|
|
* @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000)
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*/
|
|
private ?int $id = null;
|
|
|
|
/**
|
|
* This is a workaround for client, to allow them to assign arbitrary data
|
|
* dedicated to their job.
|
|
*
|
|
* This data is not persisted into database, but will appears on the data
|
|
* normalized during the same request (like PUT/PATCH request)
|
|
*
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"write"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*
|
|
* @var mixed
|
|
*/
|
|
private $key;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(
|
|
* targetEntity=StoredObject::class,
|
|
* )
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"write"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*/
|
|
private ?StoredObject $storedObject = null;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(
|
|
* targetEntity=DocGeneratorTemplate::class
|
|
* )
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*/
|
|
private ?DocGeneratorTemplate $template = null;
|
|
|
|
/**
|
|
* @ORM\Column(type="text", nullable=false, options={"default": ""})
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"write"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*/
|
|
private ?string $title = '';
|
|
|
|
/**
|
|
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*/
|
|
private ?\DateTimeImmutable $updatedAt = null;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(
|
|
* targetEntity=User::class
|
|
* )
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
|
*/
|
|
private ?User $updatedBy = null;
|
|
|
|
public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation
|
|
{
|
|
return $this->accompanyingPeriodWorkEvaluation;
|
|
}
|
|
|
|
/**
|
|
* @return \DateTimeImmutable|null
|
|
*/
|
|
public function getCreatedAt(): ?DateTimeInterface
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function getCreatedBy(): ?User
|
|
{
|
|
return $this->createdBy;
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getKey()
|
|
{
|
|
return $this->key;
|
|
}
|
|
|
|
public function getStoredObject(): ?StoredObject
|
|
{
|
|
return $this->storedObject;
|
|
}
|
|
|
|
public function getTemplate(): ?DocGeneratorTemplate
|
|
{
|
|
return $this->template;
|
|
}
|
|
|
|
public function getTitle(): ?string
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
/**
|
|
* @return DateTimeImmutable|null
|
|
*/
|
|
public function getUpdatedAt(): ?DateTimeInterface
|
|
{
|
|
return $this->updatedAt;
|
|
}
|
|
|
|
public function getUpdatedBy(): ?User
|
|
{
|
|
return $this->updatedBy;
|
|
}
|
|
|
|
public function setAccompanyingPeriodWorkEvaluation(?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation): AccompanyingPeriodWorkEvaluationDocument
|
|
{
|
|
// if an evaluation is already associated, we cannot change the association (removing the association,
|
|
// by setting a null value, is allowed.
|
|
if (
|
|
$this->accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation
|
|
&& $accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation
|
|
) {
|
|
if ($this->accompanyingPeriodWorkEvaluation !== $accompanyingPeriodWorkEvaluation) {
|
|
throw new RuntimeException('It is not allowed to change the evaluation for a document');
|
|
}
|
|
}
|
|
$this->accompanyingPeriodWorkEvaluation = $accompanyingPeriodWorkEvaluation;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setCreatedAt(DateTimeInterface $datetime): TrackCreationInterface
|
|
{
|
|
$this->createdAt = $datetime;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setCreatedBy(User $user): TrackCreationInterface
|
|
{
|
|
$this->createdBy = $user;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $key
|
|
*
|
|
* @return AccompanyingPeriodWorkEvaluationDocument
|
|
*/
|
|
public function setKey($key)
|
|
{
|
|
$this->key = $key;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setStoredObject(?StoredObject $storedObject): AccompanyingPeriodWorkEvaluationDocument
|
|
{
|
|
$this->storedObject = $storedObject;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setTemplate(?DocGeneratorTemplate $template): AccompanyingPeriodWorkEvaluationDocument
|
|
{
|
|
$this->template = $template;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setTitle(?string $title): AccompanyingPeriodWorkEvaluationDocument
|
|
{
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
|
|
{
|
|
$this->updatedAt = $datetime;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setUpdatedBy(User $user): TrackUpdateInterface
|
|
{
|
|
$this->updatedBy = $user;
|
|
|
|
return $this;
|
|
}
|
|
}
|