mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
154 lines
3.9 KiB
PHP
154 lines
3.9 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\PersonBundle\Entity\AccompanyingPeriod;
|
|
|
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
|
use Chill\MainBundle\Entity\User;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_comment' => Comment::class])]
|
|
#[ORM\Entity]
|
|
#[ORM\Table(name: 'chill_person_accompanying_period_comment')]
|
|
class Comment implements TrackCreationInterface, TrackUpdateInterface
|
|
{
|
|
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class, inversedBy: 'comments')]
|
|
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
|
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
|
|
|
#[Groups(['read', 'write', 'docgen:read'])]
|
|
#[Assert\NotBlank]
|
|
#[Assert\NotNull]
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])]
|
|
private string $content = '';
|
|
|
|
#[Groups(['read', 'docgen:read'])]
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
|
|
private ?\DateTimeInterface $createdAt = null;
|
|
|
|
#[Groups(['read', 'docgen:read'])]
|
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?User $creator = null;
|
|
|
|
#[Groups(['read', 'docgen:read'])]
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
|
private ?int $id = null;
|
|
|
|
#[Groups(['read'])]
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
|
|
private ?\DateTimeInterface $updatedAt = null;
|
|
|
|
#[Groups(['read'])]
|
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?User $updatedBy = null;
|
|
|
|
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
|
{
|
|
return $this->accompanyingPeriod;
|
|
}
|
|
|
|
public function getContent(): string
|
|
{
|
|
return $this->content;
|
|
}
|
|
|
|
public function getCreatedAt(): ?\DateTimeInterface
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function getCreator(): ?User
|
|
{
|
|
return $this->creator;
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getUpdatedAt(): ?\DateTimeInterface
|
|
{
|
|
return $this->updatedAt;
|
|
}
|
|
|
|
public function getUpdatedBy(): ?User
|
|
{
|
|
return $this->updatedBy;
|
|
}
|
|
|
|
public function isPinned(): bool
|
|
{
|
|
return $this->getAccompanyingPeriod()->getPinnedComment() === $this;
|
|
}
|
|
|
|
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
|
{
|
|
$this->accompanyingPeriod = $accompanyingPeriod;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setContent(string $content): self
|
|
{
|
|
$this->content = $content;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
|
{
|
|
$this->createdAt = $createdAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setCreatedBy(User $user): self
|
|
{
|
|
return $this->setCreator($user);
|
|
}
|
|
|
|
public function setCreator(?User $creator): self
|
|
{
|
|
$this->creator = $creator;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedBy(): ?User
|
|
{
|
|
return $this->getCreator();
|
|
}
|
|
|
|
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
|
{
|
|
$this->updatedAt = $updatedAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setUpdatedBy(User $updatedBy): self
|
|
{
|
|
$this->updatedBy = $updatedBy;
|
|
|
|
return $this;
|
|
}
|
|
}
|