src/Entity/Website/Cms/Category.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Website\Cms;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Website\Website\Website;
  5. use App\Repository\Website\Cms\CategoryRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  10. #[ORM\Entity(repositoryClassCategoryRepository::class)]
  11. class Category extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'guid'uniquetrue)]
  15.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  16.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  17.     private ?string $id null;
  18.     #[ORM\Column(length100)]
  19.     private string $name;
  20.     #[ORM\Column(length150uniquetrue)]
  21.     private string $slug;
  22.     #[ORM\Column(type'text'nullabletrue)]
  23.     private ?string $description null;
  24.     // SEO
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $metaTitle null;
  27.     #[ORM\Column(type'text'nullabletrue)]
  28.     private ?string $metaDescription null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $ogImage null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $canonicalUrl null;
  33.     #[ORM\Column(nullabletrue)]
  34.     private ?bool $noIndex false;
  35.     #[ORM\Column(nullabletrue)]
  36.     private ?bool $noFollow false;
  37.     #[ORM\Column(length100nullabletrue)]
  38.     private ?string $schemaType 'CollectionPage';
  39.     #[ORM\Column(type'json'nullabletrue)]
  40.     private ?array $schemaData null;
  41.     #[ORM\OneToMany(mappedBy'category'targetEntityArticle::class)]
  42.     private Collection $articles;
  43.     #[ORM\ManyToOne(inversedBy'categories')]
  44.     #[ORM\JoinColumn(nullablefalse)]
  45.     private ?Website $website null;
  46.     public function __construct()
  47.     {
  48.         parent::__construct();
  49.         $this->articles = new ArrayCollection();
  50.     }
  51.     public function getId(): ?string
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): Category
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getSlug(): string
  65.     {
  66.         return $this->slug;
  67.     }
  68.     public function setSlug(string $slug): Category
  69.     {
  70.         $this->slug $slug;
  71.         return $this;
  72.     }
  73.     public function getDescription(): ?string
  74.     {
  75.         return $this->description;
  76.     }
  77.     public function setDescription(?string $description): Category
  78.     {
  79.         $this->description $description;
  80.         return $this;
  81.     }
  82.     public function getMetaTitle(): ?string
  83.     {
  84.         return $this->metaTitle;
  85.     }
  86.     public function setMetaTitle(?string $metaTitle): Category
  87.     {
  88.         $this->metaTitle $metaTitle;
  89.         return $this;
  90.     }
  91.     public function getMetaDescription(): ?string
  92.     {
  93.         return $this->metaDescription;
  94.     }
  95.     public function setMetaDescription(?string $metaDescription): Category
  96.     {
  97.         $this->metaDescription $metaDescription;
  98.         return $this;
  99.     }
  100.     public function getOgImage(): ?string
  101.     {
  102.         return $this->ogImage;
  103.     }
  104.     public function setOgImage(?string $ogImage): Category
  105.     {
  106.         $this->ogImage $ogImage;
  107.         return $this;
  108.     }
  109.     public function getCanonicalUrl(): ?string
  110.     {
  111.         return $this->canonicalUrl;
  112.     }
  113.     public function setCanonicalUrl(?string $canonicalUrl): Category
  114.     {
  115.         $this->canonicalUrl $canonicalUrl;
  116.         return $this;
  117.     }
  118.     public function getNoIndex(): ?bool
  119.     {
  120.         return $this->noIndex;
  121.     }
  122.     public function setNoIndex(?bool $noIndex): Category
  123.     {
  124.         $this->noIndex $noIndex;
  125.         return $this;
  126.     }
  127.     public function getNoFollow(): ?bool
  128.     {
  129.         return $this->noFollow;
  130.     }
  131.     public function setNoFollow(?bool $noFollow): Category
  132.     {
  133.         $this->noFollow $noFollow;
  134.         return $this;
  135.     }
  136.     public function getSchemaType(): ?string
  137.     {
  138.         return $this->schemaType;
  139.     }
  140.     public function setSchemaType(?string $schemaType): Category
  141.     {
  142.         $this->schemaType $schemaType;
  143.         return $this;
  144.     }
  145.     public function getSchemaData(): ?array
  146.     {
  147.         return $this->schemaData;
  148.     }
  149.     public function setSchemaData(?array $schemaData): Category
  150.     {
  151.         $this->schemaData $schemaData;
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Collection<int, Article>
  156.      */
  157.     public function getArticles(): Collection
  158.     {
  159.         return $this->articles;
  160.     }
  161.     public function addArticle(Article $article): static
  162.     {
  163.         if (!$this->articles->contains($article)) {
  164.             $this->articles->add($article);
  165.             $article->setCategory($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeArticle(Article $article): static
  170.     {
  171.         if ($this->articles->removeElement($article)) {
  172.             // set the owning side to null (unless already changed)
  173.             if ($article->getCategory() === $this) {
  174.                 $article->setCategory(null);
  175.             }
  176.         }
  177.         return $this;
  178.     }
  179.     public function getWebsite(): ?Website
  180.     {
  181.         return $this->website;
  182.     }
  183.     public function setWebsite(?Website $website): static
  184.     {
  185.         $this->website $website;
  186.         return $this;
  187.     }
  188. }