src/Entity/Tag.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  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\TagRepository")
  8.  *
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class Tag
  12. {
  13.     public function __construct()
  14.     {
  15.         $this->article_tags = new ArrayCollection();
  16.     }
  17.     /**
  18.      * @ORM\Id()
  19.      *
  20.      * @ORM\GeneratedValue()
  21.      *
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", nullable=false, length=180)
  27.      */
  28.     private $name null;
  29.     /**
  30.      * @ORM\Column(type="string", nullable=true, length=180)
  31.      */
  32.     private $slug null;
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName()
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName($name)
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getSlug()
  47.     {
  48.         return $this->slug;
  49.     }
  50.     public function setSlug($slug)
  51.     {
  52.         $this->slug $slug;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @ORM\Column(type="datetime", nullable=false)
  57.      */
  58.     private $created_at;
  59.     /**
  60.      * @ORM\Column(type="datetime", nullable=true)
  61.      */
  62.     private $updated_at null;
  63.     public function getCreatedAt(): \DateTimeInterface
  64.     {
  65.         return $this->created_at;
  66.     }
  67.     public function setCreatedAt(\DateTimeInterface $created_at): self
  68.     {
  69.         $this->created_at $created_at;
  70.         return $this;
  71.     }
  72.     public function getUpdatedAt(): ?\DateTimeInterface
  73.     {
  74.         return $this->updated_at;
  75.     }
  76.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  77.     {
  78.         $this->updated_at $updated_at;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @ORM\PrePersist
  83.      */
  84.     public function setCreatedAtValue()
  85.     {
  86.         $this->setCreatedAt(new \DateTime());
  87.     }
  88.     /**
  89.      * @ORM\PreUpdate
  90.      */
  91.     public function setUpdatedAtValue()
  92.     {
  93.         $this->setUpdatedAt(new \DateTime());
  94.     }
  95.     /**
  96.      * @ORM\Column(type="datetime", nullable=true)
  97.      */
  98.     private $deleted_at;
  99.     public function getDeletedAt(): ?\DateTimeInterface
  100.     {
  101.         return $this->deleted_at;
  102.     }
  103.     public function setDeletedAt(?\DateTimeInterface $deleted_at): self
  104.     {
  105.         $this->deleted_at $deleted_at;
  106.         return $this;
  107.     }
  108.     // Target of a LinkedEntity from TagController (Controller)
  109.     /**
  110.      * @ORM\OneToMany(targetEntity="App\Entity\ArticleTag", mappedBy="tag")
  111.      */
  112.     private $article_tags;
  113.     /**
  114.      * @ORM\Column(type="integer", nullable=true)
  115.      */
  116.     private $legacy_id;
  117.     /**
  118.      * @return Collection|ArticleTag[]
  119.      */
  120.     public function getArticleTags(): Collection
  121.     {
  122.         return $this->article_tags;
  123.     }
  124.     public function addArticleTag(ArticleTag $article_tag): self
  125.     {
  126.         if (!$this->article_tags->contains($article_tag)) {
  127.             $this->article_tags[] = $article_tag;
  128.             $article_tag->setTag($this);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removeArticleTag(ArticleTag $article_tag): self
  133.     {
  134.         if ($this->article_tags->contains($article_tag)) {
  135.             $this->article_tags->removeElement($article_tag);
  136.             if ($article_tag->getTag() === $this) {
  137.                 $article_tag->setTag(null);
  138.             }
  139.         }
  140.         return $this;
  141.     }
  142.     public function getLegacyId(): ?int
  143.     {
  144.         return $this->legacy_id;
  145.     }
  146.     public function setLegacyId(?int $legacy_id): self
  147.     {
  148.         $this->legacy_id $legacy_id;
  149.         return $this;
  150.     }
  151. }