src/Entity/Website/Blog/Article.php line 17

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