src/Entity/Gos/ShortUrlDictionary.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\Gos\ShortUrlDictionaryRepository")
  8.  */
  9. class ShortUrlDictionary
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=255)
  19.      */
  20.     private $value;
  21.     /**
  22.      * @ORM\OneToMany(
  23.      *      targetEntity="ShortUrlDictionary",
  24.      *      mappedBy="parent",
  25.      *      cascade={"persist", "remove"})
  26.      * )
  27.      *
  28.      **/
  29.     private $children;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity="ShortUrlDictionary", inversedBy="children")
  32.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
  33.      **/
  34.     private $parent;
  35.     public function __construct()
  36.     {
  37.         $this->children = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getValue(): ?string
  44.     {
  45.         return $this->value;
  46.     }
  47.     public function setValue(string $value): self
  48.     {
  49.         $this->value $value;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection|ShortUrlDictionary[]
  54.      */
  55.     public function getChildren(): Collection
  56.     {
  57.         return $this->children;
  58.     }
  59.     public function addChild(ShortUrlDictionary $child): self
  60.     {
  61.         if (!$this->children->contains($child)) {
  62.             $this->children[] = $child;
  63.             $child->setParent($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeChild(ShortUrlDictionary $child): self
  68.     {
  69.         if ($this->children->contains($child)) {
  70.             $this->children->removeElement($child);
  71.             // set the owning side to null (unless already changed)
  72.             if ($child->getParent() === $this) {
  73.                 $child->setParent(null);
  74.             }
  75.         }
  76.         return $this;
  77.     }
  78.     public function getParent(): ?self
  79.     {
  80.         return $this->parent;
  81.     }
  82.     public function setParent(?self $parent): self
  83.     {
  84.         $this->parent $parent;
  85.         return $this;
  86.     }
  87. }