src/Entity/Shop/Blog/Article.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Blog;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Generic\Customer\Customer;
  5. use App\Entity\Shop\Shop\Shop;
  6. use App\Repository\Shop\Blog\ArticleRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  12. #[ORM\Entity(repositoryClassArticleRepository::class)]
  13. class Article extends BaseEntity
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\Column(type'guid'uniquetrue)]
  17.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  18.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  19.     private ?string $id;
  20.     #[ORM\ManyToOne(inversedBy'articles')]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?Shop $shop null;
  23.     #[ORM\Column(length255)]
  24.     private ?string $title null;
  25.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  26.     private ?string $content null;
  27.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  28.     private ?string $excerpt null;
  29.     #[ORM\Column]
  30.     private ?bool $published null;
  31.     #[ORM\ManyToOne(inversedBy'articles')]
  32.     #[ORM\JoinColumn(nullablefalse)]
  33.     private ?Customer $author null;
  34.     #[ORM\ManyToMany(targetEntityCategory::class, mappedBy'articles')]
  35.     private Collection $categories;
  36.     #[ORM\ManyToMany(targetEntityTag::class, mappedBy'articles')]
  37.     private Collection $tags;
  38.     #[ORM\OneToMany(mappedBy'article'targetEntityComment::class)]
  39.     private Collection $comments;
  40.     public function __construct()
  41.     {
  42.         parent::__construct();
  43.         $this->categories = new ArrayCollection();
  44.         $this->tags = new ArrayCollection();
  45.         $this->comments = new ArrayCollection();
  46.     }
  47.     public function getId(): ?string
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getShop(): ?Shop
  52.     {
  53.         return $this->shop;
  54.     }
  55.     public function setShop(?Shop $shop): static
  56.     {
  57.         $this->shop $shop;
  58.         return $this;
  59.     }
  60.     public function getTitle(): ?string
  61.     {
  62.         return $this->title;
  63.     }
  64.     public function setTitle(string $title): static
  65.     {
  66.         $this->title $title;
  67.         return $this;
  68.     }
  69.     public function getContent(): ?string
  70.     {
  71.         return $this->content;
  72.     }
  73.     public function setContent(?string $content): static
  74.     {
  75.         $this->content $content;
  76.         return $this;
  77.     }
  78.     public function getExcerpt(): ?string
  79.     {
  80.         return $this->excerpt;
  81.     }
  82.     public function setExcerpt(?string $excerpt): static
  83.     {
  84.         $this->excerpt $excerpt;
  85.         return $this;
  86.     }
  87.     public function isPublished(): ?bool
  88.     {
  89.         return $this->published;
  90.     }
  91.     public function setPublished(bool $published): static
  92.     {
  93.         $this->published $published;
  94.         return $this;
  95.     }
  96.     public function getAuthor(): ?Customer
  97.     {
  98.         return $this->author;
  99.     }
  100.     public function setAuthor(?Customer $author): static
  101.     {
  102.         $this->author $author;
  103.         return $this;
  104.     }
  105.     /**
  106.      * @return Collection<int, Category>
  107.      */
  108.     public function getCategories(): Collection
  109.     {
  110.         return $this->categories;
  111.     }
  112.     public function addCategory(Category $category): static
  113.     {
  114.         if (!$this->categories->contains($category)) {
  115.             $this->categories->add($category);
  116.             $category->addArticle($this);
  117.         }
  118.         return $this;
  119.     }
  120.     public function removeCategory(Category $category): static
  121.     {
  122.         if ($this->categories->removeElement($category)) {
  123.             $category->removeArticle($this);
  124.         }
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection<int, Tag>
  129.      */
  130.     public function getTags(): Collection
  131.     {
  132.         return $this->tags;
  133.     }
  134.     public function addTag(Tag $tag): static
  135.     {
  136.         if (!$this->tags->contains($tag)) {
  137.             $this->tags->add($tag);
  138.             $tag->addArticle($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeTag(Tag $tag): static
  143.     {
  144.         if ($this->tags->removeElement($tag)) {
  145.             $tag->removeArticle($this);
  146.         }
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return Collection<int, Comment>
  151.      */
  152.     public function getComments(): Collection
  153.     {
  154.         return $this->comments;
  155.     }
  156.     public function addComment(Comment $comment): static
  157.     {
  158.         if (!$this->comments->contains($comment)) {
  159.             $this->comments->add($comment);
  160.             $comment->setArticle($this);
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeComment(Comment $comment): static
  165.     {
  166.         if ($this->comments->removeElement($comment)) {
  167.             // set the owning side to null (unless already changed)
  168.             if ($comment->getArticle() === $this) {
  169.                 $comment->setArticle(null);
  170.             }
  171.         }
  172.         return $this;
  173.     }
  174. }