src/Entity/HierarchyVersion.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\DBAL\Types\Types;
  4. use App\Repository\HierarchyVersionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use App\Validator\Constraints as AppAssert;
  9. use Gedmo\Timestampable\Traits\TimestampableEntity;
  10. #[ORM\Entity(repositoryClassHierarchyVersionRepository::class)]
  11. #[AppAssert\LatestHierarchyVersionConstraint]
  12. class HierarchyVersion
  13. {
  14.     use TimestampableEntity;
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $name null;
  21.     #[ORM\OneToMany(mappedBy'hierarchyVersion'targetEntityHierarchy::class, orphanRemovaltruefetch'EAGER'cascade: ['persist''remove'])]
  22.     private Collection $hierarchies;
  23.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  24.     private ?\DateTimeInterface $effectiveStartDate null;
  25.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  26.     private ?\DateTimeInterface $effectiveEndDate null;
  27.     public function __construct()
  28.     {
  29.         $this->hierarchies = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getName(): ?string
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function setName(string $name): static
  40.     {
  41.         $this->name $name;
  42.         return $this;
  43.     }
  44.     /**
  45.      * @return Collection<int, Hierarchy>
  46.      */
  47.     public function getHierarchies(): Collection
  48.     {
  49.         return $this->hierarchies;
  50.     }
  51.     public function addHierarchy(Hierarchy $hierarchy): static
  52.     {
  53.         if (!$this->hierarchies->contains($hierarchy)) {
  54.             $this->hierarchies->add($hierarchy);
  55.             $hierarchy->setHierarchyVersion($this);
  56.         }
  57.         return $this;
  58.     }
  59.     public function removeHierarchy(Hierarchy $hierarchy): static
  60.     {
  61.         if ($this->hierarchies->removeElement($hierarchy)) {
  62.             // set the owning side to null (unless already changed)
  63.             if ($hierarchy->getHierarchyVersion() === $this) {
  64.                 $hierarchy->setHierarchyVersion(null);
  65.             }
  66.         }
  67.         return $this;
  68.     }
  69.     public function getEffectiveStartDate(): ?\DateTimeInterface
  70.     {
  71.         return $this->effectiveStartDate;
  72.     }
  73.     public function setEffectiveStartDate(?\DateTimeInterface $effectiveStartDate): static
  74.     {
  75.         $this->effectiveStartDate $effectiveStartDate;
  76.         return $this;
  77.     }
  78.     public function getEffectiveEndDate(): ?\DateTimeInterface
  79.     {
  80.         return $this->effectiveEndDate;
  81.     }
  82.     public function setEffectiveEndDate(?\DateTimeInterface $effectiveEndDate): static
  83.     {
  84.         $this->effectiveEndDate $effectiveEndDate;
  85.         return $this;
  86.     }
  87.     public function __toString()
  88.     {
  89.         return (string) $this->name;
  90.     }
  91. }