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. use App\Entity\Instance;
  9. /**
  10.  * @ORM\Entity(repositoryClass=BlogPostCategoryRepository::class)
  11.  */
  12. class BlogPostCategory implements WithQRCodeInterfacePositionedInterface
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=100)
  22.      */
  23.     private $title;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $slug;
  28.     /**
  29.      * @ORM\Column(type="boolean")
  30.      */
  31.     private $isActivated false;
  32.     /**
  33.      * @ORM\Column(type="datetime")
  34.      */
  35.     private $createdAt;
  36.     /**
  37.      * @ORM\Column(type="datetime")
  38.      */
  39.     private $updatedAt;
  40.     /**
  41.      * @ORM\Column(type="integer")
  42.      */
  43.     private $position;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private $qrCode;
  48.     /**
  49.      * @ORM\Column(type="boolean")
  50.      */
  51.     private $isPublic;
  52.     /**
  53.      * @ORM\OneToOne(targetEntity=Seo::class, cascade={"persist", "remove"})
  54.      */
  55.     private $seo;
  56.     /**
  57.      * @ORM\OneToMany(targetEntity=BlogPost::class, mappedBy="blogPostCategory")
  58.      */
  59.     private $blogPosts;
  60.     /**
  61.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="blogPostCategories")
  62.      */
  63.     private $users;
  64.     /**
  65.      * @ORM\ManyToMany(targetEntity=Roles::class)
  66.      */
  67.     private $roles;
  68.     /**
  69.      * @ORM\Column(type="boolean", nullable=true)
  70.      */
  71.     private $hasAllCriteria1;
  72.     /**
  73.      * @ORM\ManyToMany(targetEntity=Criteria1Item::class, inversedBy="blogPostCategories")
  74.      */
  75.     private $criteria1Items;
  76.     /**
  77.      * @ORM\Column(type="boolean", nullable=true)
  78.      */
  79.     private $hasAllCriteria2;
  80.     /**
  81.      * @ORM\ManyToMany(targetEntity=Criteria2Item::class)
  82.      */
  83.     private $criteria2Items;
  84.     /**
  85.      * @ORM\Column(type="boolean", nullable=true)
  86.      */
  87.     private $hasAllCriteria3;
  88.     /**
  89.      * @ORM\ManyToMany(targetEntity=Criteria3Item::class)
  90.      */
  91.     private $criteria3Items;
  92.     /**
  93.      * @ORM\Column(type="boolean", nullable=true)
  94.      */
  95.     private $hasAllCriteria4;
  96.     /**
  97.      * @ORM\ManyToMany(targetEntity=Criteria4Item::class)
  98.      */
  99.     private $criteria4Items;
  100.     /**
  101.      * @ORM\Column(type="boolean", nullable=true)
  102.      */
  103.     private $hasAllCriteria5;
  104.     /**
  105.      * @ORM\ManyToMany(targetEntity=Criteria5Item::class)
  106.      */
  107.     private $criteria5Items;
  108.     /**
  109.      * @ORM\ManyToMany(targetEntity=Instance::class, inversedBy="blogPostCategories")
  110.      */
  111.     private Collection $instances;
  112.     /**
  113.      * BlogPostCategory constructor.
  114.      */
  115.     public function __construct()
  116.     {
  117.         $this->blogPosts = new ArrayCollection();
  118.         $this->createdAt = new \DateTime();
  119.         $this->updatedAt = new \DateTime();
  120.         $this->users = new ArrayCollection();
  121.         $this->roles = new ArrayCollection();
  122.         $this->criteria1Items = new ArrayCollection();
  123.         $this->criteria2Items = new ArrayCollection();
  124.         $this->criteria3Items = new ArrayCollection();
  125.         $this->criteria4Items = new ArrayCollection();
  126.         $this->criteria5Items = new ArrayCollection();
  127.         $this->instances = new ArrayCollection();
  128.     }
  129.     /**
  130.      * @return int|null
  131.      */
  132.     public function getId(): ?int
  133.     {
  134.         return $this->id;
  135.     }
  136.     /**
  137.      * @return string|null
  138.      */
  139.     public function getTitle(): ?string
  140.     {
  141.         return $this->title;
  142.     }
  143.     /**
  144.      * @param string $title
  145.      * @return $this
  146.      */
  147.     public function setTitle(string $title): self
  148.     {
  149.         $this->title $title;
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return string|null
  154.      */
  155.     public function getSlug(): ?string
  156.     {
  157.         return $this->slug;
  158.     }
  159.     /**
  160.      * @param string $slug
  161.      * @return $this
  162.      */
  163.     public function setSlug(string $slug): self
  164.     {
  165.         $this->slug $slug;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return bool|null
  170.      */
  171.     public function getIsActivated(): ?bool
  172.     {
  173.         return $this->isActivated;
  174.     }
  175.     /**
  176.      * @param bool $isActivated
  177.      * @return $this
  178.      */
  179.     public function setIsActivated(bool $isActivated): self
  180.     {
  181.         $this->isActivated $isActivated;
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return \DateTimeInterface|null
  186.      */
  187.     public function getCreatedAt(): ?\DateTimeInterface
  188.     {
  189.         return $this->createdAt;
  190.     }
  191.     /**
  192.      * @param \DateTimeInterface $createdAt
  193.      * @return $this
  194.      */
  195.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  196.     {
  197.         $this->createdAt $createdAt;
  198.         return $this;
  199.     }
  200.     /**
  201.      * @return \DateTimeInterface|null
  202.      */
  203.     public function getUpdatedAt(): ?\DateTimeInterface
  204.     {
  205.         return $this->updatedAt;
  206.     }
  207.     /**
  208.      * @param \DateTimeInterface $updatedAt
  209.      * @return $this
  210.      */
  211.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  212.     {
  213.         $this->updatedAt $updatedAt;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return Collection<int, BlogPost>
  218.      */
  219.     public function getBlogPosts(): Collection
  220.     {
  221.         return $this->blogPosts;
  222.     }
  223.     public function addBlogPost(BlogPost $blogPost): self
  224.     {
  225.         if (!$this->blogPosts->contains($blogPost)) {
  226.             $this->blogPosts[] = $blogPost;
  227.             $blogPost->setBlogPostCategory($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function removeBlogPost(BlogPost $blogPost): self
  232.     {
  233.         if ($this->blogPosts->removeElement($blogPost)) {
  234.             // set the owning side to null (unless already changed)
  235.             if ($blogPost->getBlogPostCategory() === $this) {
  236.                 $blogPost->setBlogPostCategory(null);
  237.             }
  238.         }
  239.         return $this;
  240.     }
  241.     public function getPosition(): ?int
  242.     {
  243.         return $this->position;
  244.     }
  245.     public function setPosition(int $position): self
  246.     {
  247.         $this->position $position;
  248.         return $this;
  249.     }
  250.     public function getQrCode(): ?string
  251.     {
  252.         return $this->qrCode;
  253.     }
  254.     public function setQrCode(string $qrCode): self
  255.     {
  256.         $this->qrCode $qrCode;
  257.         return $this;
  258.     }
  259.     public function getQrCodeRouteName(): string
  260.     {
  261.         return 'categorie';
  262.     }
  263.     public function getQrCodeRouteParams(): array
  264.     {
  265.         return [
  266.             'slug' => $this->getSlug(),
  267.         ];
  268.     }
  269.     public function getIsPublic(): ?bool
  270.     {
  271.         return $this->isPublic;
  272.     }
  273.     public function setIsPublic(bool $isPublic): self
  274.     {
  275.         $this->isPublic $isPublic;
  276.         return $this;
  277.     }
  278.     /**
  279.      * @return Collection<int, User>
  280.      */
  281.     public function getUsers(): Collection
  282.     {
  283.         return $this->users;
  284.     }
  285.     public function addUser(User $user): self
  286.     {
  287.         if (!$this->users->contains($user)) {
  288.             $this->users[] = $user;
  289.         }
  290.         return $this;
  291.     }
  292.     public function removeUser(User $user): self
  293.     {
  294.         if ($this->users->contains($user)) {
  295.             $this->users->removeElement($user);
  296.         }
  297.         return $this;
  298.     }
  299.     public function getSeo(): ?Seo
  300.     {
  301.         return $this->seo;
  302.     }
  303.     public function setSeo(?Seo $seo): self
  304.     {
  305.         $this->seo $seo;
  306.         return $this;
  307.     }
  308.     /**
  309.      * @return Collection<int, Roles>
  310.      */
  311.     public function getRoles(): Collection
  312.     {
  313.         return $this->roles;
  314.     }
  315.     public function addRole(Roles $role): self
  316.     {
  317.         if (!$this->roles->contains($role)) {
  318.             $this->roles[] = $role;
  319.         }
  320.         return $this;
  321.     }
  322.     public function removeRole(Roles $role): self
  323.     {
  324.         $this->roles->removeElement($role);
  325.         return $this;
  326.     }
  327.     public function isHasAllCriteria1(): ?bool
  328.     {
  329.         return $this->hasAllCriteria1;
  330.     }
  331.     public function setHasAllCriteria1(?bool $hasAllCriteria1): self
  332.     {
  333.         $this->hasAllCriteria1 $hasAllCriteria1;
  334.         return $this;
  335.     }
  336.     /**
  337.      * @return Collection<int, Criteria1Item>
  338.      */
  339.     public function getCriteria1Items(): Collection
  340.     {
  341.         return $this->criteria1Items;
  342.     }
  343.     public function addCriteria1Item(Criteria1Item $criteria1Item): self
  344.     {
  345.         if (!$this->criteria1Items->contains($criteria1Item)) {
  346.             $this->criteria1Items[] = $criteria1Item;
  347.         }
  348.         return $this;
  349.     }
  350.     public function removeCriteria1Item(Criteria1Item $criteria1Item): self
  351.     {
  352.         $this->criteria1Items->removeElement($criteria1Item);
  353.         return $this;
  354.     }
  355.     public function isHasAllCriteria2(): ?bool
  356.     {
  357.         return $this->hasAllCriteria2;
  358.     }
  359.     public function setHasAllCriteria2(?bool $hasAllCriteria2): self
  360.     {
  361.         $this->hasAllCriteria2 $hasAllCriteria2;
  362.         return $this;
  363.     }
  364.     /**
  365.      * @return Collection<int, Criteria2Item>
  366.      */
  367.     public function getCriteria2Items(): Collection
  368.     {
  369.         return $this->criteria2Items;
  370.     }
  371.     public function addCriteria2Item(Criteria2Item $criteria2Item): self
  372.     {
  373.         if (!$this->criteria2Items->contains($criteria2Item)) {
  374.             $this->criteria2Items[] = $criteria2Item;
  375.         }
  376.         return $this;
  377.     }
  378.     public function removeCriteria2Item(Criteria2Item $criteria2Item): self
  379.     {
  380.         $this->criteria2Items->removeElement($criteria2Item);
  381.         return $this;
  382.     }
  383.     public function isHasAllCriteria3(): ?bool
  384.     {
  385.         return $this->hasAllCriteria3;
  386.     }
  387.     public function setHasAllCriteria3(?bool $hasAllCriteria3): self
  388.     {
  389.         $this->hasAllCriteria3 $hasAllCriteria3;
  390.         return $this;
  391.     }
  392.     /**
  393.      * @return Collection<int, Criteria3Item>
  394.      */
  395.     public function getCriteria3Items(): Collection
  396.     {
  397.         return $this->criteria3Items;
  398.     }
  399.     public function addCriteria3Item(Criteria3Item $criteria3Item): self
  400.     {
  401.         if (!$this->criteria3Items->contains($criteria3Item)) {
  402.             $this->criteria3Items[] = $criteria3Item;
  403.         }
  404.         return $this;
  405.     }
  406.     public function removeCriteria3Item(Criteria3Item $criteria3Item): self
  407.     {
  408.         $this->criteria3Items->removeElement($criteria3Item);
  409.         return $this;
  410.     }
  411.     public function isHasAllCriteria4(): ?bool
  412.     {
  413.         return $this->hasAllCriteria4;
  414.     }
  415.     public function setHasAllCriteria4(?bool $hasAllCriteria4): self
  416.     {
  417.         $this->hasAllCriteria4 $hasAllCriteria4;
  418.         return $this;
  419.     }
  420.     /**
  421.      * @return Collection<int, Criteria4Item>
  422.      */
  423.     public function getCriteria4Items(): Collection
  424.     {
  425.         return $this->criteria4Items;
  426.     }
  427.     public function addCriteria4Item(Criteria4Item $criteria4Item): self
  428.     {
  429.         if (!$this->criteria4Items->contains($criteria4Item)) {
  430.             $this->criteria4Items[] = $criteria4Item;
  431.         }
  432.         return $this;
  433.     }
  434.     public function removeCriteria4Item(Criteria4Item $criteria4Item): self
  435.     {
  436.         $this->criteria4Items->removeElement($criteria4Item);
  437.         return $this;
  438.     }
  439.     public function isHasAllCriteria5(): ?bool
  440.     {
  441.         return $this->hasAllCriteria5;
  442.     }
  443.     public function setHasAllCriteria5(?bool $hasAllCriteria5): self
  444.     {
  445.         $this->hasAllCriteria5 $hasAllCriteria5;
  446.         return $this;
  447.     }
  448.     /**
  449.      * @return Collection<int, Criteria5Item>
  450.      */
  451.     public function getCriteria5Items(): Collection
  452.     {
  453.         return $this->criteria5Items;
  454.     }
  455.     public function addCriteria5Item(Criteria5Item $criteria5Item): self
  456.     {
  457.         if (!$this->criteria5Items->contains($criteria5Item)) {
  458.             $this->criteria5Items[] = $criteria5Item;
  459.         }
  460.         return $this;
  461.     }
  462.     public function removeCriteria5Item(Criteria5Item $criteria5Item): self
  463.     {
  464.         $this->criteria5Items->removeElement($criteria5Item);
  465.         return $this;
  466.     }
  467.     public function __toString(): string
  468.     {
  469.         return $this->getTitle() ?? '';
  470.     }
  471.     /**
  472.      * @return Collection<int, Instance>
  473.      */
  474.     public function getInstances(): Collection
  475.     {
  476.         return $this->instances;
  477.     }
  478.     public function addInstance(Instance $instance): self
  479.     {
  480.         if (!$this->instances->contains($instance)) {
  481.             $this->instances[] = $instance;
  482.         }
  483.         return $this;
  484.     }
  485.     public function removeInstance(Instance $instance): self
  486.     {
  487.         $this->instances->removeElement($instance);
  488.         return $this;
  489.     }
  490.     public function getInstancesList(): string
  491.     {
  492.         return implode(', '$this->instances->toArray());
  493.     }
  494. }