<?php
namespace App\Entity\BC;
use App\Repository\BC\ProcessTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProcessTypeRepository::class)]
#[ORM\HasLifecycleCallbacks]
class ProcessType
{
#[ORM\Id]
#[ORM\Column(type: 'string', length: 64)]
private string $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $description = null;
#[ORM\ManyToOne(targetEntity: SubscriptionModel::class, inversedBy: 'processTypes')]
#[ORM\JoinColumn(name: 'subscription_model_id', referencedColumnName: 'id', nullable: false)]
private SubscriptionModel $subscriptionModel;
#[ORM\OneToMany(mappedBy: 'processType', targetEntity: PositionType::class, cascade: ['persist'], orphanRemoval: false)]
private Collection $positionTypes;
#[ORM\Column(type: 'datetime_immutable')]
private \DateTimeImmutable $createdAt;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private \DateTimeImmutable $updatedAt;
public function __construct(string $id)
{
$this->id = $id;
$this->positionTypes = new ArrayCollection();
}
#[ORM\PrePersist]
public function onPrePersist(): void
{
$now = new \DateTimeImmutable();
$this->createdAt = $now;
}
#[ORM\PreUpdate]
public function onPreUpdate(): void
{
$this->updatedAt = new \DateTimeImmutable();
}
public function getId(): string
{
return $this->id;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): void
{
$this->description = $description;
}
public function getSubscriptionModel(): SubscriptionModel
{
return $this->subscriptionModel;
}
public function setSubscriptionModel(SubscriptionModel $subscriptionModel): void
{
$this->subscriptionModel = $subscriptionModel;
}
public function getPositionTypes(): Collection
{
return $this->positionTypes;
}
public function addPositionType(PositionType $positionType): void
{
if (!$this->positionTypes->contains($positionType)) {
$this->positionTypes->add($positionType);
$positionType->setProcessType($this);
}
}
public function getCreatedAt(): \DateTimeImmutable
{
return $this->createdAt;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
}