src/Entity/ContactSheet/ContactSheet.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ContactSheet;
  3. use App\Validator\Constraints as AppAssert;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\App\ContactSheet\ContactSheetRepository")
  12.  * @UniqueEntity(fields={"deliveryStationId", "contractNumber"}, message="contact_sheet.form.already_exist")
  13.  */
  14. class ContactSheet
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=50)
  24.      * @Assert\NotBlank
  25.      */
  26.     private $deliveryStationId;
  27.     /**
  28.      * @ORM\Column(type="string", length=50)
  29.      * @Assert\NotBlank
  30.      */
  31.     private $contractNumber;
  32.     /**
  33.      * @ORM\Column(type="string", length=50)
  34.      * @Assert\NotBlank
  35.      */
  36.     private $customerNumber;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity="App\Entity\ContactSheet\InterruptionContact", mappedBy="contactSheet", orphanRemoval=true, cascade={"persist"})
  39.      */
  40.     private $interruptionContacts;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity="App\Entity\ContactSheet\PriorityContact", mappedBy="contactSheet", orphanRemoval=true, cascade={"persist"})
  43.      * @Assert\Count(min="1", minMessage="contact_sheet.form.priority_contacts_minimun")
  44.      * @AppAssert\ContactSheetPriorityContacts
  45.      */
  46.     private $priorityContacts;
  47.     /**
  48.      * @ORM\Column(type="text", nullable=true)
  49.      * @Assert\Length(max=500)
  50.      */
  51.     private $additionalInformation;
  52.     /**
  53.      * @ORM\Column(type="datetime")
  54.      * @Gedmo\Timestampable(on="update")
  55.      */
  56.     private $updatedAt;
  57.     /**
  58.      * @ORM\Column(name="file_name", nullable=true)
  59.      */
  60.     protected $fileName;
  61.     /**
  62.      * @ORM\Column(name="file_size", type="integer", nullable=true)
  63.      */
  64.     protected $fileSize;
  65.     public function __construct(string $deliveryStationIdstring $contractNumberstring $customerNumber)
  66.     {
  67.         $this->updatedAt = new \DateTimeImmutable();
  68.         $this->setDeliveryStationId($deliveryStationId);
  69.         $this->setContractNumber($contractNumber);
  70.         $this->setCustomerNumber($customerNumber);
  71.         $this->interruptionContacts = new ArrayCollection();
  72.         $this->priorityContacts = new ArrayCollection();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getDeliveryStationId(): ?string
  79.     {
  80.         return $this->deliveryStationId;
  81.     }
  82.     public function setDeliveryStationId(string $deliveryStationId): self
  83.     {
  84.         $this->deliveryStationId $deliveryStationId;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @return Collection|InterruptionContact[]
  89.      */
  90.     public function getInterruptionContacts(): Collection
  91.     {
  92.         return $this->interruptionContacts;
  93.     }
  94.     public function addInterruptionContact(InterruptionContact $interruptionContact): self
  95.     {
  96.         if (!$this->interruptionContacts->contains($interruptionContact)) {
  97.             $this->interruptionContacts[] = $interruptionContact;
  98.             $interruptionContact->setContactSheet($this);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removeInterruptionContact(InterruptionContact $interruptionContact): self
  103.     {
  104.         if ($this->interruptionContacts->contains($interruptionContact)) {
  105.             $this->interruptionContacts->removeElement($interruptionContact);
  106.             if ($interruptionContact->getContactSheet() === $this) {
  107.                 $interruptionContact->setContactSheet(null);
  108.             }
  109.         }
  110.         return $this;
  111.     }
  112.     /**
  113.      * @return Collection|PriorityContact[]
  114.      */
  115.     public function getPriorityContacts(): Collection
  116.     {
  117.         return $this->priorityContacts;
  118.     }
  119.     public function addPriorityContact(PriorityContact $priorityContact): self
  120.     {
  121.         if (!$this->priorityContacts->contains($priorityContact)) {
  122.             $this->priorityContacts[] = $priorityContact;
  123.             $priorityContact->setContactSheet($this);
  124.         }
  125.         return $this;
  126.     }
  127.     public function removePriorityContact(PriorityContact $priorityContact): self
  128.     {
  129.         if ($this->priorityContacts->contains($priorityContact)) {
  130.             $this->priorityContacts->removeElement($priorityContact);
  131.             if ($priorityContact->getContactSheet() === $this) {
  132.                 $priorityContact->setContactSheet(null);
  133.             }
  134.         }
  135.         return $this;
  136.     }
  137.     public function getAdditionalInformation(): ?string
  138.     {
  139.         return $this->additionalInformation;
  140.     }
  141.     public function setAdditionalInformation(?string $additionalInformation): self
  142.     {
  143.         $this->additionalInformation $additionalInformation;
  144.         return $this;
  145.     }
  146.     public function getUpdatedAt(): ?\DateTimeInterface
  147.     {
  148.         return $this->updatedAt;
  149.     }
  150.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  151.     {
  152.         $this->updatedAt $updatedAt;
  153.         return $this;
  154.     }
  155.     public function getFileName(): ?string
  156.     {
  157.         return $this->fileName;
  158.     }
  159.     public function setFileName(?string $fileName): void
  160.     {
  161.         $this->fileName $fileName;
  162.     }
  163.     public function getFileSize(): ?int
  164.     {
  165.         return $this->fileSize;
  166.     }
  167.     public function setFileSize(?int $fileSize): void
  168.     {
  169.         $this->fileSize $fileSize;
  170.     }
  171.     public function setContractNumber(string $contractNumber): void
  172.     {
  173.         $this->contractNumber $contractNumber;
  174.     }
  175.     public function getContractNumber(): string
  176.     {
  177.         return $this->contractNumber;
  178.     }
  179.     public function setCustomerNumber(string $customerNumber): void
  180.     {
  181.         $this->customerNumber $customerNumber;
  182.     }
  183.     public function getCustomerNumber(): string
  184.     {
  185.         return $this->customerNumber;
  186.     }
  187. }