src/Entity/Gos/ContactItem.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\ContactItemRepository")
  8.  */
  9. class ContactItem
  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 $title;
  21.     /**
  22.      * @ORM\Column(type="text")
  23.      */
  24.     private $description;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $breadcrumb;
  29.     /**
  30.      * @ORM\OneToMany(
  31.      *      targetEntity="ContactItem",
  32.      *      mappedBy="parent",
  33.      *      cascade={"persist", "remove"})
  34.      * )
  35.      *
  36.      **/
  37.     private $children;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity="ContactItem", inversedBy="children")
  40.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
  41.      **/
  42.     private $parent;
  43.     public function __construct()
  44.     {
  45.         $this->children = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getTitle(): ?string
  52.     {
  53.         return $this->title;
  54.     }
  55.     public function setTitle(string $title): self
  56.     {
  57.         $this->title $title;
  58.         return $this;
  59.     }
  60.     public function getDescription(): ?string
  61.     {
  62.         return $this->description;
  63.     }
  64.     public function setDescription(string $description): self
  65.     {
  66.         $this->description $description;
  67.         return $this;
  68.     }
  69.     public function getBreadcrumb(): ?string
  70.     {
  71.         return $this->breadcrumb;
  72.     }
  73.     public function setBreadcrumb(string $breadcrumb): self
  74.     {
  75.         $this->breadcrumb $breadcrumb;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection|ContactItem[]
  80.      */
  81.     public function getChildren(): Collection
  82.     {
  83.         return $this->children;
  84.     }
  85.     public function addChild(ContactItem $child): self
  86.     {
  87.         if (!$this->children->contains($child)) {
  88.             $this->children[] = $child;
  89.             $child->setParent($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeChild(ContactItem $child): self
  94.     {
  95.         if ($this->children->contains($child)) {
  96.             $this->children->removeElement($child);
  97.             // set the owning side to null (unless already changed)
  98.             if ($child->getParent() === $this) {
  99.                 $child->setParent(null);
  100.             }
  101.         }
  102.         return $this;
  103.     }
  104.     public function getParent(): ?self
  105.     {
  106.         return $this->parent;
  107.     }
  108.     public function setParent(?self $parent): self
  109.     {
  110.         $this->parent $parent;
  111.         return $this;
  112.     }
  113. }