<?php
namespace App\Entity\ContactSheet;
use App\Validator\Constraints as AppAssert;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\App\ContactSheet\ContactSheetRepository")
* @UniqueEntity(fields={"deliveryStationId", "contractNumber"}, message="contact_sheet.form.already_exist")
*/
class ContactSheet
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=50)
* @Assert\NotBlank
*/
private $deliveryStationId;
/**
* @ORM\Column(type="string", length=50)
* @Assert\NotBlank
*/
private $contractNumber;
/**
* @ORM\Column(type="string", length=50)
* @Assert\NotBlank
*/
private $customerNumber;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContactSheet\InterruptionContact", mappedBy="contactSheet", orphanRemoval=true, cascade={"persist"})
*/
private $interruptionContacts;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContactSheet\PriorityContact", mappedBy="contactSheet", orphanRemoval=true, cascade={"persist"})
* @Assert\Count(min="1", minMessage="contact_sheet.form.priority_contacts_minimun")
* @AppAssert\ContactSheetPriorityContacts
*/
private $priorityContacts;
/**
* @ORM\Column(type="text", nullable=true)
* @Assert\Length(max=500)
*/
private $additionalInformation;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\Column(name="file_name", nullable=true)
*/
protected $fileName;
/**
* @ORM\Column(name="file_size", type="integer", nullable=true)
*/
protected $fileSize;
public function __construct(string $deliveryStationId, string $contractNumber, string $customerNumber)
{
$this->updatedAt = new \DateTimeImmutable();
$this->setDeliveryStationId($deliveryStationId);
$this->setContractNumber($contractNumber);
$this->setCustomerNumber($customerNumber);
$this->interruptionContacts = new ArrayCollection();
$this->priorityContacts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDeliveryStationId(): ?string
{
return $this->deliveryStationId;
}
public function setDeliveryStationId(string $deliveryStationId): self
{
$this->deliveryStationId = $deliveryStationId;
return $this;
}
/**
* @return Collection|InterruptionContact[]
*/
public function getInterruptionContacts(): Collection
{
return $this->interruptionContacts;
}
public function addInterruptionContact(InterruptionContact $interruptionContact): self
{
if (!$this->interruptionContacts->contains($interruptionContact)) {
$this->interruptionContacts[] = $interruptionContact;
$interruptionContact->setContactSheet($this);
}
return $this;
}
public function removeInterruptionContact(InterruptionContact $interruptionContact): self
{
if ($this->interruptionContacts->contains($interruptionContact)) {
$this->interruptionContacts->removeElement($interruptionContact);
if ($interruptionContact->getContactSheet() === $this) {
$interruptionContact->setContactSheet(null);
}
}
return $this;
}
/**
* @return Collection|PriorityContact[]
*/
public function getPriorityContacts(): Collection
{
return $this->priorityContacts;
}
public function addPriorityContact(PriorityContact $priorityContact): self
{
if (!$this->priorityContacts->contains($priorityContact)) {
$this->priorityContacts[] = $priorityContact;
$priorityContact->setContactSheet($this);
}
return $this;
}
public function removePriorityContact(PriorityContact $priorityContact): self
{
if ($this->priorityContacts->contains($priorityContact)) {
$this->priorityContacts->removeElement($priorityContact);
if ($priorityContact->getContactSheet() === $this) {
$priorityContact->setContactSheet(null);
}
}
return $this;
}
public function getAdditionalInformation(): ?string
{
return $this->additionalInformation;
}
public function setAdditionalInformation(?string $additionalInformation): self
{
$this->additionalInformation = $additionalInformation;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(?string $fileName): void
{
$this->fileName = $fileName;
}
public function getFileSize(): ?int
{
return $this->fileSize;
}
public function setFileSize(?int $fileSize): void
{
$this->fileSize = $fileSize;
}
public function setContractNumber(string $contractNumber): void
{
$this->contractNumber = $contractNumber;
}
public function getContractNumber(): string
{
return $this->contractNumber;
}
public function setCustomerNumber(string $customerNumber): void
{
$this->customerNumber = $customerNumber;
}
public function getCustomerNumber(): string
{
return $this->customerNumber;
}
}