src/Entity/BlogPostCategory.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BlogPostCategoryRepository;
  4. use App\Repository\BlogPostRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=BlogPostCategoryRepository::class)
  10.  */
  11. class BlogPostCategory implements WithQRCodeInterfacePositionedInterface
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=100)
  21.      */
  22.     private $title;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $slug;
  27.     /**
  28.      * @ORM\Column(type="boolean")
  29.      */
  30.     private $isActivated false;
  31.     /**
  32.      * @ORM\Column(type="datetime")
  33.      */
  34.     private $createdAt;
  35.     /**
  36.      * @ORM\Column(type="datetime")
  37.      */
  38.     private $updatedAt;
  39.     /**
  40.      * @ORM\Column(type="integer")
  41.      */
  42.     private $position;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $qrCode;
  47.     /**
  48.      * @ORM\Column(type="boolean")
  49.      */
  50.     private $isPublic;
  51.     /**
  52.      * @ORM\OneToOne(targetEntity=Seo::class, cascade={"persist", "remove"})
  53.      */
  54.     private $seo;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity=BlogPost::class, mappedBy="blogPostCategory")
  57.      */
  58.     private $blogPosts;
  59.     /**
  60.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="blogPostCategories")
  61.      */
  62.     private $users;
  63.     /**
  64.      * @ORM\ManyToMany(targetEntity=Roles::class)
  65.      */
  66.     private $roles;
  67.     /**
  68.      * @ORM\Column(type="boolean", nullable=true)
  69.      */
  70.     private $hasAllCriteria1;
  71.     /**
  72.      * @ORM\ManyToMany(targetEntity=Criteria1Item::class, inversedBy="blogPostCategories")
  73.      */
  74.     private $criteria1Items;
  75.     /**
  76.      * @ORM\Column(type="boolean", nullable=true)
  77.      */
  78.     private $hasAllCriteria2;
  79.     /**
  80.      * @ORM\ManyToMany(targetEntity=Criteria2Item::class)
  81.      */
  82.     private $criteria2Items;
  83.     /**
  84.      * @ORM\Column(type="boolean", nullable=true)
  85.      */
  86.     private $hasAllCriteria3;
  87.     /**
  88.      * @ORM\ManyToMany(targetEntity=Criteria3Item::class)
  89.      */
  90.     private $criteria3Items;
  91.     /**
  92.      * BlogPostCategory constructor.
  93.      */
  94.     public function __construct()
  95.     {
  96.         $this->blogPosts = new ArrayCollection();
  97.         $this->createdAt = new \DateTime();
  98.         $this->updatedAt = new \DateTime();
  99.         $this->users = new ArrayCollection();
  100.         $this->roles = new ArrayCollection();
  101.         $this->criteria1Items = new ArrayCollection();
  102.         $this->criteria2Items = new ArrayCollection();
  103.         $this->criteria3Items = new ArrayCollection();
  104.     }
  105.     /**
  106.      * @return int|null
  107.      */
  108.     public function getId(): ?int
  109.     {
  110.         return $this->id;
  111.     }
  112.     /**
  113.      * @return string|null
  114.      */
  115.     public function getTitle(): ?string
  116.     {
  117.         return $this->title;
  118.     }
  119.     /**
  120.      * @param string $title
  121.      * @return $this
  122.      */
  123.     public function setTitle(string $title): self
  124.     {
  125.         $this->title $title;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return string|null
  130.      */
  131.     public function getSlug(): ?string
  132.     {
  133.         return $this->slug;
  134.     }
  135.     /**
  136.      * @param string $slug
  137.      * @return $this
  138.      */
  139.     public function setSlug(string $slug): self
  140.     {
  141.         $this->slug $slug;
  142.         return $this;
  143.     }
  144.     /**
  145.      * @return bool|null
  146.      */
  147.     public function getIsActivated(): ?bool
  148.     {
  149.         return $this->isActivated;
  150.     }
  151.     /**
  152.      * @param bool $isActivated
  153.      * @return $this
  154.      */
  155.     public function setIsActivated(bool $isActivated): self
  156.     {
  157.         $this->isActivated $isActivated;
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return \DateTimeInterface|null
  162.      */
  163.     public function getCreatedAt(): ?\DateTimeInterface
  164.     {
  165.         return $this->createdAt;
  166.     }
  167.     /**
  168.      * @param \DateTimeInterface $createdAt
  169.      * @return $this
  170.      */
  171.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  172.     {
  173.         $this->createdAt $createdAt;
  174.         return $this;
  175.     }
  176.     /**
  177.      * @return \DateTimeInterface|null
  178.      */
  179.     public function getUpdatedAt(): ?\DateTimeInterface
  180.     {
  181.         return $this->updatedAt;
  182.     }
  183.     /**
  184.      * @param \DateTimeInterface $updatedAt
  185.      * @return $this
  186.      */
  187.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  188.     {
  189.         $this->updatedAt $updatedAt;
  190.         return $this;
  191.     }
  192.     /**
  193.      * @return Collection<int, BlogPost>
  194.      */
  195.     public function getBlogPosts(): Collection
  196.     {
  197.         return $this->blogPosts;
  198.     }
  199.     public function addBlogPost(BlogPost $blogPost): self
  200.     {
  201.         if (!$this->blogPosts->contains($blogPost)) {
  202.             $this->blogPosts[] = $blogPost;
  203.             $blogPost->setBlogPostCategory($this);
  204.         }
  205.         return $this;
  206.     }
  207.     public function removeBlogPost(BlogPost $blogPost): self
  208.     {
  209.         if ($this->blogPosts->removeElement($blogPost)) {
  210.             // set the owning side to null (unless already changed)
  211.             if ($blogPost->getBlogPostCategory() === $this) {
  212.                 $blogPost->setBlogPostCategory(null);
  213.             }
  214.         }
  215.         return $this;
  216.     }
  217.     public function getPosition(): ?int
  218.     {
  219.         return $this->position;
  220.     }
  221.     public function setPosition(int $position): self
  222.     {
  223.         $this->position $position;
  224.         return $this;
  225.     }
  226.     public function getQrCode(): ?string
  227.     {
  228.         return $this->qrCode;
  229.     }
  230.     public function setQrCode(string $qrCode): self
  231.     {
  232.         $this->qrCode $qrCode;
  233.         return $this;
  234.     }
  235.     public function getQrCodeRouteName(): string
  236.     {
  237.         return 'categorie';
  238.     }
  239.     public function getQrCodeRouteParams(): array
  240.     {
  241.         return [
  242.             'slug' => $this->getSlug(),
  243.         ];
  244.     }
  245.     public function getIsPublic(): ?bool
  246.     {
  247.         return $this->isPublic;
  248.     }
  249.     public function setIsPublic(bool $isPublic): self
  250.     {
  251.         $this->isPublic $isPublic;
  252.         return $this;
  253.     }
  254.     /**
  255.      * @return Collection<int, User>
  256.      */
  257.     public function getUsers(): Collection
  258.     {
  259.         return $this->users;
  260.     }
  261.     public function addUser(User $user): self
  262.     {
  263.         if (!$this->users->contains($user)) {
  264.             $this->users[] = $user;
  265.         }
  266.         return $this;
  267.     }
  268.     public function removeUser(User $user): self
  269.     {
  270.         if ($this->users->contains($user)) {
  271.             $this->users->removeElement($user);
  272.         }
  273.         return $this;
  274.     }
  275.     public function getSeo(): ?Seo
  276.     {
  277.         return $this->seo;
  278.     }
  279.     public function setSeo(?Seo $seo): self
  280.     {
  281.         $this->seo $seo;
  282.         return $this;
  283.     }
  284.     /**
  285.      * @return Collection<int, Roles>
  286.      */
  287.     public function getRoles(): Collection
  288.     {
  289.         return $this->roles;
  290.     }
  291.     public function addRole(Roles $role): self
  292.     {
  293.         if (!$this->roles->contains($role)) {
  294.             $this->roles[] = $role;
  295.         }
  296.         return $this;
  297.     }
  298.     public function removeRole(Roles $role): self
  299.     {
  300.         $this->roles->removeElement($role);
  301.         return $this;
  302.     }
  303.     public function isHasAllCriteria1(): ?bool
  304.     {
  305.         return $this->hasAllCriteria1;
  306.     }
  307.     public function setHasAllCriteria1(?bool $hasAllCriteria1): self
  308.     {
  309.         $this->hasAllCriteria1 $hasAllCriteria1;
  310.         return $this;
  311.     }
  312.     /**
  313.      * @return Collection<int, Criteria1Item>
  314.      */
  315.     public function getCriteria1Items(): Collection
  316.     {
  317.         return $this->criteria1Items;
  318.     }
  319.     public function addCriteria1Item(Criteria1Item $criteria1Item): self
  320.     {
  321.         if (!$this->criteria1Items->contains($criteria1Item)) {
  322.             $this->criteria1Items[] = $criteria1Item;
  323.         }
  324.         return $this;
  325.     }
  326.     public function removeCriteria1Item(Criteria1Item $criteria1Item): self
  327.     {
  328.         $this->criteria1Items->removeElement($criteria1Item);
  329.         return $this;
  330.     }
  331.     public function isHasAllCriteria2(): ?bool
  332.     {
  333.         return $this->hasAllCriteria2;
  334.     }
  335.     public function setHasAllCriteria2(?bool $hasAllCriteria2): self
  336.     {
  337.         $this->hasAllCriteria2 $hasAllCriteria2;
  338.         return $this;
  339.     }
  340.     /**
  341.      * @return Collection<int, Criteria2Item>
  342.      */
  343.     public function getCriteria2Items(): Collection
  344.     {
  345.         return $this->criteria2Items;
  346.     }
  347.     public function addCriteria2Item(Criteria2Item $criteria2Item): self
  348.     {
  349.         if (!$this->criteria2Items->contains($criteria2Item)) {
  350.             $this->criteria2Items[] = $criteria2Item;
  351.         }
  352.         return $this;
  353.     }
  354.     public function removeCriteria2Item(Criteria2Item $criteria2Item): self
  355.     {
  356.         $this->criteria2Items->removeElement($criteria2Item);
  357.         return $this;
  358.     }
  359.     public function isHasAllCriteria3(): ?bool
  360.     {
  361.         return $this->hasAllCriteria3;
  362.     }
  363.     public function setHasAllCriteria3(?bool $hasAllCriteria3): self
  364.     {
  365.         $this->hasAllCriteria3 $hasAllCriteria3;
  366.         return $this;
  367.     }
  368.     /**
  369.      * @return Collection<int, Criteria3Item>
  370.      */
  371.     public function getCriteria3Items(): Collection
  372.     {
  373.         return $this->criteria3Items;
  374.     }
  375.     public function addCriteria3Item(Criteria3Item $criteria3Item): self
  376.     {
  377.         if (!$this->criteria3Items->contains($criteria3Item)) {
  378.             $this->criteria3Items[] = $criteria3Item;
  379.         }
  380.         return $this;
  381.     }
  382.     public function removeCriteria3Item(Criteria3Item $criteria3Item): self
  383.     {
  384.         $this->criteria3Items->removeElement($criteria3Item);
  385.         return $this;
  386.     }
  387.     public function __toString(): string
  388.     {
  389.         return $this->getTitle() ?? '';
  390.     }
  391. }