src/Entity/BlogPost.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BlogPostRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  12. /**
  13.  * @ORM\Entity(repositoryClass=BlogPostRepository::class)
  14.  * @Vich\Uploadable
  15.  * @UniqueEntity(fields={"slug"}, message="Slug deja utilisé")
  16.  */
  17. class BlogPost implements WithQRCodeInterfacePositionedInterface
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=150, nullable=true)
  27.      */
  28.     private $title;
  29.     /**
  30.      * @ORM\Column(type="string", length=255, unique=true, nullable=false)
  31.      */
  32.     private $slug;
  33.     /**
  34.      * @ORM\Column(type="text", nullable=true)
  35.      * @Assert\Regex(
  36.      *     pattern="/(<\s*svg\b|data:image\/svg\+xml)/i",
  37.      *     match=false,
  38.      *     message="Les balises ou contenus SVG sont interdits dans la description."
  39.      * )
  40.      */
  41.     private $description;
  42.     /**
  43.      * @return string|null
  44.      */
  45.     public function getTitle(): ?string
  46.     {
  47.         return $this->title;
  48.     }
  49.     /**
  50.      * @param string $title
  51.      * @return $this
  52.      */
  53.     public function setTitle(string $title): self
  54.     {
  55.         $this->title $title;
  56.         return $this;
  57.     }
  58.     /**
  59.      * @return string|null
  60.      */
  61.     public function getSlug(): ?string
  62.     {
  63.         return $this->slug;
  64.     }
  65.     /**
  66.      * @param string $slug
  67.      * @return $this
  68.      */
  69.     public function setSlug(string $slug): self
  70.     {
  71.         $this->slug $slug;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return string|null
  76.      */
  77.     public function getDescription(): ?string
  78.     {
  79.         return $this->description;
  80.     }
  81.     /**
  82.      * @param ?string $description
  83.      * @return $this
  84.      */
  85.     public function setDescription(?string $description): self
  86.     {
  87.         $this->description $description;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @ORM\Column(type="boolean")
  92.      */
  93.     private $isActivated false;
  94.     /**
  95.      * @ORM\Column(type="datetime")
  96.      */
  97.     private $createdAt;
  98.     /**
  99.      * @ORM\Column(type="datetime")
  100.      */
  101.     private $updatedAt;
  102.     /**
  103.      * Rubrique parente (si sous-domaine sélectionné)
  104.      *
  105.      * @ORM\ManyToOne(targetEntity=BlogPostCategory::class, inversedBy="blogPosts")
  106.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  107.      */
  108.     private ?BlogPostCategory $blogPostCategory null;
  109.     /**
  110.      * @ORM\OneToOne(targetEntity=Seo::class, cascade={"persist", "remove"})
  111.      */
  112.     private $seo;
  113.     /**
  114.      * @ORM\Column(type="boolean", options={"default": false})
  115.      */
  116.     private $isFeatured false;
  117.     /**
  118.      * @ORM\Column(type="boolean", options={"default": false})
  119.      */
  120.     private $isFeaturedTitle false;
  121.     /**
  122.      * @ORM\OneToOne(targetEntity=Media::class, cascade={"persist"})
  123.      */
  124.     
  125.     private $imagePreviewMedia;
  126.     /**
  127.      * @ORM\OneToOne(targetEntity=Media::class, cascade={"persist", "remove"})
  128.      */
  129.     private $featuringImageMedia;
  130.     /**
  131.      * @ORM\Column(type="boolean", options={"default": false}, nullable=true)
  132.      */
  133.     private $isPublic false;
  134.     /**
  135.      * @ORM\Column(type="integer")
  136.      */
  137.     private $position 0;
  138.     /**
  139.      * @ORM\Column(type="string", length=255, nullable=true)
  140.      */
  141.     private $qrCode;
  142.     /**
  143.      * @ORM\ManyToOne(targetEntity=Media::class, cascade={"persist", "remove"})
  144.      */
  145.     private $media;
  146.     /**
  147.      * @ORM\OneToOne(targetEntity=Media::class, cascade={"persist", "remove"})
  148.      */
  149.     private $previewVideo;
  150.     /**
  151.      * @ORM\OneToMany(targetEntity=BlogPostLike::class, mappedBy="blogPost", orphanRemoval=true)
  152.      */
  153.     private $likes;
  154.     /**
  155.      * @ORM\Column(type="datetime", nullable=true)
  156.      */
  157.     private $notificationSentAt;
  158.     /**
  159.      * @ORM\OneToOne(inversedBy="blogPost", targetEntity=BlogPostNotification::class, cascade={"persist", "remove"})
  160.      */
  161.     private $notification;
  162.     /**
  163.      * @ORM\Column(type="boolean", options={"default": false}, nullable=true)
  164.      */
  165.     private $isNotify;
  166.     /**
  167.      * @ORM\Column(type="boolean", options={"default": false}, nullable=true)
  168.      */
  169.     private $isScheduled false;
  170.     /**
  171.      * @ORM\OneToMany(targetEntity=BlogPostHistoryUpdate::class, mappedBy="blogPost", orphanRemoval=true)
  172.      */
  173.     private $blogPostHistoryUpdates;
  174.     /**
  175.      * @ORM\ManyToOne(targetEntity=Preference::class, inversedBy="blogPosts")
  176.      */
  177.     private $preference;
  178.     /**
  179.      * @ORM\ManyToMany(targetEntity=Roles::class)
  180.      */
  181.     private $roles;
  182.     /**
  183.      * @ORM\Column(type="datetime", nullable=true)
  184.      */
  185.     private $activation_date;
  186.     /**
  187.      * @ORM\Column(type="datetime", nullable=true)
  188.      */
  189.     private $desactivation_date;
  190.     /**
  191.      * @ORM\OneToMany(targetEntity=BlogPostGallery::class, mappedBy="blogPost", cascade={"remove"})
  192.      */
  193.     private $galleries;
  194.     /**
  195.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="blogPosts")
  196.      */
  197.     private $author;
  198.     /**
  199.      * @ORM\Column(type="boolean", nullable=true)
  200.      */
  201.     private $hasAllCriteria1;
  202.     /**
  203.      * @ORM\ManyToMany(targetEntity=Criteria1Item::class)
  204.      */
  205.     private $criteria1Items;
  206.     /**
  207.      * @ORM\Column(type="boolean", nullable=true)
  208.      */
  209.     private $hasAllCriteria2;
  210.     /**
  211.      * @ORM\ManyToMany(targetEntity=Criteria2Item::class)
  212.      */
  213.     private $criteria2Items;
  214.     /**
  215.      * @ORM\Column(type="boolean", nullable=true)
  216.      */
  217.     private $hasAllCriteria3;
  218.     /**
  219.      * @ORM\ManyToMany(targetEntity=Criteria3Item::class)
  220.      */
  221.     private $criteria3Items;
  222.     /**
  223.      * @ORM\Column(type="boolean", nullable=true)
  224.      */
  225.     private $hasAllCriteria4;
  226.    /**
  227.  * @ORM\ManyToMany(targetEntity=Criteria4Item::class)
  228.  * @ORM\JoinTable(name="blog_post_criteria4_item")
  229.  */
  230. private Collection $criteria4Items;
  231.     /**
  232.      * @ORM\Column(type="boolean", nullable=true)
  233.      */
  234.     private $hasAllCriteria5;
  235.  /**
  236.  * @ORM\ManyToMany(targetEntity=Criteria5Item::class)
  237.  * @ORM\JoinTable(name="blog_post_criteria5_item")
  238.  */
  239. private Collection $criteria5Items;
  240.     /**
  241.      * @ORM\OneToOne(targetEntity=ScoringQuiz::class, mappedBy="blogPost", cascade={"persist", "remove"})
  242.      */
  243.     private $scoringQuiz;
  244.     /**
  245.      * @ORM\OneToOne(targetEntity=IdentityForm::class, mappedBy="blogPost", cascade={"persist", "remove"})
  246.      */
  247.     private $identityForm;
  248.     /**
  249.      * @ORM\Column(type="string", length=255, nullable=true)
  250.      */
  251.     private $identityField1;
  252.     /**
  253.      * @ORM\Column(type="string", length=255, nullable=true)
  254.      */
  255.     private $identityField2;
  256.     /**
  257.      * @ORM\Column(type="string", length=255, nullable=true)
  258.      */
  259.     private $identityField3;
  260.     /**
  261.      * @ORM\Column(type="string", length=255, nullable=true)
  262.      */
  263.     private $identityField4;
  264.     /**
  265.      * @ORM\Column(type="string", length=255, nullable=true)
  266.      */
  267.     private $identityField5;
  268.     /**
  269.      * @ORM\Column(type="string", length=255, nullable=true)
  270.      */
  271.     private $identityField6;
  272.     /**
  273.      * @ORM\Column(type="string", length=255, nullable=true)
  274.      */
  275.     private $identityField7;
  276.     /**
  277.      * @ORM\Column(type="text", nullable=true)
  278.      */
  279.     private $identityTextarea;
  280.     /**
  281.      * @ORM\Column(type="string", nullable=true)
  282.      */
  283.     private $identityMedia;
  284.     /**
  285.      * @Vich\UploadableField(mapping="identity_media", fileNameProperty="identityMedia")
  286.      * @var File|null
  287.      */
  288.     private $identityMediaFile;
  289.     /**
  290.      * @ORM\OneToMany(targetEntity=UserIdentityForm::class, mappedBy="blogPost", cascade={"persist", "remove"}, orphanRemoval=true)
  291.      */
  292.     private $userIdentityForms;
  293.     /**
  294.      * @ORM\ManyToMany(targetEntity=Instance::class, inversedBy="blogPosts")
  295.      */
  296.     private Collection $instances;
  297.     /**
  298.      * Domaine parent (sélecteur) – obligatoire
  299.      *
  300.      * @ORM\ManyToOne(targetEntity=Domain::class)
  301.      * @ORM\JoinColumn(nullable=false)
  302.      *
  303.      * @Assert\NotNull(message="Le domaine est obligatoire.")
  304.      */
  305.     private ?Domain $domain null;
  306.     /**
  307.      * Sous-domaine parent – optionnel
  308.      * Utilisé pour rattacher le contenu à une rubrique
  309.      *
  310.      * @ORM\ManyToOne(targetEntity=SubDomain::class)
  311.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  312.      */
  313.     private ?SubDomain $subDomain null;
  314.     /**
  315.      * @ORM\Column(type="boolean", options={"default": false})
  316.      */
  317.     private bool $isHome false;
  318.     /**
  319.      * Position du contenu sur la page HOME (uniquement si isHome = true)
  320.      * @ORM\Column(type="integer", nullable=true)
  321.      */
  322.     private ?int $homePosition null;
  323.     public function __construct()
  324.     {
  325.         $this->createdAt = new \DateTime();
  326.         $this->updatedAt = new \DateTime();
  327.         $this->likes = new ArrayCollection();
  328.         $this->blogPostHistoryUpdates = new ArrayCollection();
  329.         $this->roles = new ArrayCollection();
  330.         $this->galleries = new ArrayCollection();
  331.         $this->criteria1Items = new ArrayCollection();
  332.         $this->criteria2Items = new ArrayCollection();
  333.         $this->criteria3Items = new ArrayCollection();
  334.         $this->criteria4Items = new ArrayCollection();
  335.         $this->criteria5Items = new ArrayCollection();
  336.         $this->userIdentityForms = new ArrayCollection();
  337.         $this->instances = new ArrayCollection();
  338.     }
  339.     /**
  340.      * @return int|null
  341.      */
  342.     public function getId(): ?int
  343.     {
  344.         return $this->id;
  345.     }
  346.     /**
  347.      * @return bool|null
  348.      */
  349.     public function getIsActivated(): ?bool
  350.     {
  351.         return $this->isActivated;
  352.     }
  353.     /**
  354.      * @param bool $isActivated
  355.      * @return $this
  356.      */
  357.     public function setIsActivated(bool $isActivated): self
  358.     {
  359.         $this->isActivated $isActivated;
  360.         return $this;
  361.     }
  362.     /**
  363.      * @return \DateTimeInterface|null
  364.      */
  365.     public function getCreatedAt(): ?\DateTimeInterface
  366.     {
  367.         return $this->createdAt;
  368.     }
  369.     /**
  370.      * @param \DateTimeInterface $createdAt
  371.      * @return $this
  372.      */
  373.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  374.     {
  375.         $this->createdAt $createdAt;
  376.         return $this;
  377.     }
  378.     /**
  379.      * @return \DateTimeInterface|null
  380.      */
  381.     public function getUpdatedAt(): ?\DateTimeInterface
  382.     {
  383.         return $this->updatedAt;
  384.     }
  385.     /**
  386.      * @param \DateTimeInterface $updatedAt
  387.      * @return $this
  388.      */
  389.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  390.     {
  391.         $this->updatedAt $updatedAt;
  392.         return $this;
  393.     }
  394.     public function getBlogPostCategory(): ?BlogPostCategory
  395.     {
  396.         return $this->blogPostCategory;
  397.     }
  398.     public function setBlogPostCategory(?BlogPostCategory $blogPostCategory): self
  399.     {
  400.         $this->blogPostCategory $blogPostCategory;
  401.         return $this;
  402.     }
  403.     public function __toString(): string
  404.     {
  405.         return $this->getTitle() ?? '';
  406.     }
  407.     public function getSeo(): ?Seo
  408.     {
  409.         return $this->seo;
  410.     }
  411.     public function setSeo(?Seo $seo): self
  412.     {
  413.         $this->seo $seo;
  414.         return $this;
  415.     }
  416.     public function getMetadatas(): ?string
  417.     {
  418.         return $this->getSeo()?->getMetadatas();
  419.     }
  420.     public function getIsFeatured(): ?bool
  421.     {
  422.         return $this->isFeatured;
  423.     }
  424.     public function setIsFeatured(bool $isFeatured): self
  425.     {
  426.         $this->isFeatured $isFeatured;
  427.         return $this;
  428.     }
  429.     public function getIsFeaturedTitle(): ?bool
  430.     {
  431.         return $this->isFeaturedTitle;
  432.     }
  433.     public function setIsFeaturedTitle(bool $isFeaturedTitle): self
  434.     {
  435.         $this->isFeaturedTitle $isFeaturedTitle;
  436.         return $this;
  437.     }
  438.     public function getImagePreviewMedia(): ?Media
  439.     {
  440.         return $this->imagePreviewMedia;
  441.     }
  442.     public function setImagePreviewMedia(?Media $imagePreviewMedia): self
  443.     {
  444.         $this->imagePreviewMedia $imagePreviewMedia;
  445.         return $this;
  446.     }
  447.     public function getFeaturingImageMedia(): ?Media
  448.     {
  449.         return $this->featuringImageMedia;
  450.     }
  451.     public function setFeaturingImageMedia(?Media $featuringImageMedia): self
  452.     {
  453.         $this->featuringImageMedia $featuringImageMedia;
  454.         return $this;
  455.     }
  456.     public function getIsPublic(): ?bool
  457.     {
  458.         return $this->isPublic;
  459.     }
  460.     public function setIsPublic(bool $isPublic): self
  461.     {
  462.         $this->isPublic $isPublic;
  463.         return $this;
  464.     }
  465.     public function getPosition(): ?int
  466.     {
  467.         return $this->position;
  468.     }
  469.     public function setPosition(int $position): self
  470.     {
  471.         $this->position $position;
  472.         return $this;
  473.     }
  474.     public function getIsPrivate(): bool
  475.     {
  476.         return !$this->isPublic;
  477.     }
  478.     public function getQrCode(): ?string
  479.     {
  480.         return $this->qrCode;
  481.     }
  482.     public function setQrCode(string $qrCode): self
  483.     {
  484.         $this->qrCode $qrCode;
  485.         return $this;
  486.     }
  487.     public function getQrCodeRouteName(): string
  488.     {
  489.         return 'podcast';
  490.     }
  491.     public function getQrCodeRouteParams(): array
  492.     {
  493.         return [
  494.             'slug' => $this->getSlug(),
  495.         ];
  496.     }
  497.     public function getMedia(): ?Media
  498.     {
  499.         return $this->media;
  500.     }
  501.     public function setMedia(?Media $media): self
  502.     {
  503.         $this->media $media;
  504.         return $this;
  505.     }
  506.     public function getPreviewVideo(): ?Media
  507.     {
  508.         return $this->previewVideo;
  509.     }
  510.     public function setPreviewVideo(?Media $previewVideo): self
  511.     {
  512.         $this->previewVideo $previewVideo;
  513.         return $this;
  514.     }
  515.     /**
  516.      * @return Collection|BlogPostLike[]
  517.      */
  518.     public function getLikes(): Collection
  519.     {
  520.         return $this->likes;
  521.     }
  522.     public function getLikeCount(): int
  523.     {
  524.         return $this->likes->count();
  525.     }
  526.     public function isLikedBy(?User $user): bool
  527.     {
  528.         return $this->likes->exists(function (int $index) use ($user) {
  529.             $like $this->likes->get($index);
  530.             return $user && $like->getUser() === $user;
  531.         });
  532.     }
  533.     public function addLike(BlogPostLike $like): self
  534.     {
  535.         if (!$this->likes->contains($like)) {
  536.             $this->likes[] = $like;
  537.             $like->setBlogPost($this);
  538.         }
  539.         return $this;
  540.     }
  541.     public function removeLike(BlogPostLike $like): self
  542.     {
  543.         if ($this->likes->removeElement($like)) {
  544.             // set the owning side to null (unless already changed)
  545.             if ($like->getBlogPost() === $this) {
  546.                 $like->setBlogPost(null);
  547.             }
  548.         }
  549.         return $this;
  550.     }
  551.     /**
  552.      * @return \DateTimeInterface|null
  553.      */
  554.     public function getNotificationSentAt(): ?\DateTimeInterface
  555.     {
  556.         return $this->notificationSentAt;
  557.     }
  558.     public function setNotificationSentAt(?\DateTimeInterface $notificationSentAt): self
  559.     {
  560.         $this->notificationSentAt $notificationSentAt;
  561.         return $this;
  562.     }
  563.     public function getNotification(): ?BlogPostNotification
  564.     {
  565.         return $this->notification;
  566.     }
  567.     public function getNotificationTitle(): ?string
  568.     {
  569.         return $this->notification?->getTitle();
  570.     }
  571.     public function getNotificationDescription(): ?string
  572.     {
  573.         return $this->notification?->getDescription();
  574.     }
  575.     public function getNotificationAt(): ?\DateTimeInterface
  576.     {
  577.         return $this->getNotificationSentAt();
  578.     }
  579.     public function setNotification(?BlogPostNotification $notification): self
  580.     {
  581.         $this->notification $notification;
  582.         return $this;
  583.     }
  584.     public function getIsNotify(): ?bool
  585.     {
  586.         return $this->isNotify;
  587.     }
  588.     public function setIsNotify(bool $isNotify): self
  589.     {
  590.         $this->isNotify $isNotify;
  591.         return $this;
  592.     }
  593.     public function getIsScheduled(): ?bool
  594.     {
  595.         return $this->isScheduled;
  596.     }
  597.     public function setIsScheduled(bool $isScheduled): self
  598.     {
  599.         $this->isScheduled $isScheduled;
  600.         return $this;
  601.     }
  602.     /**
  603.      * @return Collection<int, BlogPostHistoryUpdate>
  604.      */
  605.     public function getBlogPostHistoryUpdates(): Collection
  606.     {
  607.         return $this->blogPostHistoryUpdates;
  608.     }
  609.     public function addBlogPostHistoryUpdate(BlogPostHistoryUpdate $blogPostHistoryUpdate): self
  610.     {
  611.         if (!$this->blogPostHistoryUpdates->contains($blogPostHistoryUpdate)) {
  612.             $this->blogPostHistoryUpdates[] = $blogPostHistoryUpdate;
  613.             $blogPostHistoryUpdate->setBlogPost($this);
  614.         }
  615.         return $this;
  616.     }
  617.     public function removeBlogPostHistoryUpdate(BlogPostHistoryUpdate $blogPostHistoryUpdate): self
  618.     {
  619.         if ($this->blogPostHistoryUpdates->removeElement($blogPostHistoryUpdate)) {
  620.             // set the owning side to null (unless already changed)
  621.             if ($blogPostHistoryUpdate->getBlogPost() === $this) {
  622.                 $blogPostHistoryUpdate->setBlogPost(null);
  623.             }
  624.         }
  625.         return $this;
  626.     }
  627.     public function getPreference(): ?Preference
  628.     {
  629.         return $this->preference;
  630.     }
  631.     public function setPreference(?Preference $preference): self
  632.     {
  633.         $this->preference $preference;
  634.         return $this;
  635.     }
  636.     /**
  637.      * @return Collection<int, Roles>
  638.      */
  639.     public function getRoles(): Collection
  640.     {
  641.         return $this->roles;
  642.     }
  643.     public function addRole(Roles $role): self
  644.     {
  645.         if (!$this->roles->contains($role)) {
  646.             $this->roles[] = $role;
  647.         }
  648.         return $this;
  649.     }
  650.     public function setRoles(Collection $roles): self
  651.     {
  652.         $this->roles $roles;
  653.         return $this;
  654.     }
  655.     public function removeRole(Roles $role): self
  656.     {
  657.         $this->roles->removeElement($role);
  658.         return $this;
  659.     }
  660.     public function convertRoleToArray()
  661.     {
  662.         $rolesArray = [];
  663.         foreach ($this->roles as $role) {
  664.             $rolesArray[] = $role->getCode();
  665.         }
  666.         return $rolesArray;
  667.     }
  668.     public function getActivationDate(): ?\DateTimeInterface
  669.     {
  670.         return $this->activation_date;
  671.     }
  672.     public function setActivationDate(?\DateTimeInterface $activation_date): self
  673.     {
  674.         $this->activation_date $activation_date;
  675.         return $this;
  676.     }
  677.     public function getDesactivationDate(): ?\DateTimeInterface
  678.     {
  679.         return $this->desactivation_date;
  680.     }
  681.     public function setDesactivationDate(?\DateTimeInterface $desactivation_date): self
  682.     {
  683.         $this->desactivation_date $desactivation_date;
  684.         return $this;
  685.     }
  686.     /**
  687.      * @return Collection<int, BlogPostGallery>
  688.      */
  689.     public function getGalleries(): Collection
  690.     {
  691.         return $this->galleries;
  692.     }
  693.     public function addGallery(BlogPostGallery $gallery): self
  694.     {
  695.         if (!$this->galleries->contains($gallery)) {
  696.             $this->galleries[] = $gallery;
  697.             $gallery->setBlogPost($this);
  698.         }
  699.         return $this;
  700.     }
  701.     public function removeGallery(BlogPostGallery $gallery): self
  702.     {
  703.         if ($this->galleries->removeElement($gallery)) {
  704.             // set the owning side to null (unless already changed)
  705.             if ($gallery->getBlogPost() === $this) {
  706.                 $gallery->setBlogPost(null);
  707.             }
  708.         }
  709.         return $this;
  710.     }
  711.     public function getAuthor(): ?User
  712.     {
  713.         return $this->author;
  714.     }
  715.     public function setAuthor(?User $author): self
  716.     {
  717.         $this->author $author;
  718.         return $this;
  719.     }
  720.     public function isHasAllCriteria1(): ?bool
  721.     {
  722.         return $this->hasAllCriteria1;
  723.     }
  724.     public function setHasAllCriteria1(?bool $hasAllCriteria1): self
  725.     {
  726.         $this->hasAllCriteria1 $hasAllCriteria1;
  727.         return $this;
  728.     }
  729.     /**
  730.      * @return Collection<int, Criteria1Item>
  731.      */
  732.     public function getCriteria1Items(): Collection
  733.     {
  734.         return $this->criteria1Items;
  735.     }
  736.     public function addCriteria1Item(Criteria1Item $criteria1Item): self
  737.     {
  738.         if (!$this->criteria1Items->contains($criteria1Item)) {
  739.             $this->criteria1Items[] = $criteria1Item;
  740.         }
  741.         return $this;
  742.     }
  743.     public function removeCriteria1Item(Criteria1Item $criteria1Item): self
  744.     {
  745.         $this->criteria1Items->removeElement($criteria1Item);
  746.         return $this;
  747.     }
  748.     public function isHasAllCriteria2(): ?bool
  749.     {
  750.         return $this->hasAllCriteria2;
  751.     }
  752.     public function setHasAllCriteria2(?bool $hasAllCriteria2): self
  753.     {
  754.         $this->hasAllCriteria2 $hasAllCriteria2;
  755.         return $this;
  756.     }
  757.     /**
  758.      * @return Collection<int, Criteria2Item>
  759.      */
  760.     public function getCriteria2Items(): Collection
  761.     {
  762.         return $this->criteria2Items;
  763.     }
  764.     public function addCriteria2Item(Criteria2Item $criteria2Item): self
  765.     {
  766.         if (!$this->criteria2Items->contains($criteria2Item)) {
  767.             $this->criteria2Items[] = $criteria2Item;
  768.         }
  769.         return $this;
  770.     }
  771.     public function removeCriteria2Item(Criteria2Item $criteria2Item): self
  772.     {
  773.         $this->criteria2Items->removeElement($criteria2Item);
  774.         return $this;
  775.     }
  776.     public function isHasAllCriteria3(): ?bool
  777.     {
  778.         return $this->hasAllCriteria3;
  779.     }
  780.     public function setHasAllCriteria3(?bool $hasAllCriteria3): self
  781.     {
  782.         $this->hasAllCriteria3 $hasAllCriteria3;
  783.         return $this;
  784.     }
  785.     /**
  786.      * @return Collection<int, Criteria3Item>
  787.      */
  788.     public function getCriteria3Items(): Collection
  789.     {
  790.         return $this->criteria3Items;
  791.     }
  792.     public function addCriteria3Item(Criteria3Item $criteria3Item): self
  793.     {
  794.         if (!$this->criteria3Items->contains($criteria3Item)) {
  795.             $this->criteria3Items[] = $criteria3Item;
  796.         }
  797.         return $this;
  798.     }
  799.     public function removeCriteria3Item(Criteria3Item $criteria3Item): self
  800.     {
  801.         $this->criteria3Items->removeElement($criteria3Item);
  802.         return $this;
  803.     }
  804.     public function isHasAllCriteria4(): ?bool
  805.     {
  806.         return $this->hasAllCriteria4;
  807.     }
  808.     public function setHasAllCriteria4(?bool $hasAllCriteria4): self
  809.     {
  810.         $this->hasAllCriteria4 $hasAllCriteria4;
  811.         return $this;
  812.     }
  813.     /**
  814.      * @return Collection<int, Criteria4Item>
  815.      */
  816.     public function getCriteria4Items(): Collection
  817.     {
  818.         return $this->criteria4Items;
  819.     }
  820.     public function addCriteria4Item(Criteria4Item $criteria4Item): self
  821.     {
  822.         if (!$this->criteria4Items->contains($criteria4Item)) {
  823.             $this->criteria4Items[] = $criteria4Item;
  824.         }
  825.         return $this;
  826.     }
  827.     public function removeCriteria4Item(Criteria4Item $criteria4Item): self
  828.     {
  829.         $this->criteria4Items->removeElement($criteria4Item);
  830.         return $this;
  831.     }
  832.     public function isHasAllCriteria5(): ?bool
  833.     {
  834.         return $this->hasAllCriteria5;
  835.     }
  836.     public function setHasAllCriteria5(?bool $hasAllCriteria5): self
  837.     {
  838.         $this->hasAllCriteria5 $hasAllCriteria5;
  839.         return $this;
  840.     }
  841.     /**
  842.      * @return Collection<int, Criteria5Item>
  843.      */
  844.     public function getCriteria5Items(): Collection
  845.     {
  846.         return $this->criteria5Items;
  847.     }
  848.     public function addCriteria5Item(Criteria5Item $criteria5Item): self
  849.     {
  850.         if (!$this->criteria5Items->contains($criteria5Item)) {
  851.             $this->criteria5Items[] = $criteria5Item;
  852.         }
  853.         return $this;
  854.     }
  855.     public function removeCriteria5Item(Criteria5Item $criteria5Item): self
  856.     {
  857.         $this->criteria5Items->removeElement($criteria5Item);
  858.         return $this;
  859.     }
  860.     public function getScoringQuiz(): ?ScoringQuiz
  861.     {
  862.         return $this->scoringQuiz;
  863.     }
  864.     public function setScoringQuiz(?ScoringQuiz $scoringQuiz): ?self
  865.     {
  866.         $this->scoringQuiz $scoringQuiz;
  867.         return $this;
  868.     }
  869.     public function setBlogPost(ScoringQuiz $scoringQuiz): self
  870.     {
  871.         // set the owning side of the relation if necessary
  872.         if ($scoringQuiz->getBlogPost() !== $this) {
  873.             $scoringQuiz->setBlogPost($this);
  874.         }
  875.         $this->scoringQuiz $scoringQuiz;
  876.         return $this;
  877.     }
  878.     public function getIdentityForm(): ?IdentityForm
  879.     {
  880.         return $this->identityForm;
  881.     }
  882.     public function setIdentityForm(?IdentityForm $identityForm): self
  883.     {
  884.         if ($identityForm && $identityForm->getBlogPost() !== $this) {
  885.             $identityForm->setBlogPost($this);
  886.         }
  887.         $this->identityForm $identityForm;
  888.         return $this;
  889.     }
  890.     public function getIdentityField1(): ?string
  891.     {
  892.         return $this->identityField1;
  893.     }
  894.     public function setIdentityField1(?string $identityField1): self
  895.     {
  896.         $this->identityField1 $identityField1;
  897.         return $this;
  898.     }
  899.     public function getIdentityField2(): ?string
  900.     {
  901.         return $this->identityField2;
  902.     }
  903.     public function setIdentityField2(?string $identityField2): self
  904.     {
  905.         $this->identityField2 $identityField2;
  906.         return $this;
  907.     }
  908.     public function getIdentityField3(): ?string
  909.     {
  910.         return $this->identityField3;
  911.     }
  912.     public function setIdentityField3(?string $identityField3): self
  913.     {
  914.         $this->identityField3 $identityField3;
  915.         return $this;
  916.     }
  917.     public function getIdentityField4(): ?string
  918.     {
  919.         return $this->identityField4;
  920.     }
  921.     public function setIdentityField4(?string $identityField4): self
  922.     {
  923.         $this->identityField4 $identityField4;
  924.         return $this;
  925.     }
  926.     public function getIdentityField5(): ?string
  927.     {
  928.         return $this->identityField5;
  929.     }
  930.     public function setIdentityField5(?string $identityField5): self
  931.     {
  932.         $this->identityField5 $identityField5;
  933.         return $this;
  934.     }
  935.     public function getIdentityField6(): ?string
  936.     {
  937.         return $this->identityField6;
  938.     }
  939.     public function setIdentityField6(?string $identityField6): self
  940.     {
  941.         $this->identityField6 $identityField6;
  942.         return $this;
  943.     }
  944.     public function getIdentityField7(): ?string
  945.     {
  946.         return $this->identityField7;
  947.     }
  948.     public function setIdentityField7(?string $identityField7): self
  949.     {
  950.         $this->identityField7 $identityField7;
  951.         return $this;
  952.     }
  953.     public function getIdentityTextarea(): ?string
  954.     {
  955.         return $this->identityTextarea;
  956.     }
  957.     public function setIdentityTextarea(?string $identityTextarea): self
  958.     {
  959.         $this->identityTextarea $identityTextarea;
  960.         return $this;
  961.     }
  962.     public function setIdentityMediaFile(?File $file null): void
  963.     {
  964.         $this->identityMediaFile $file;
  965.         if (null !== $file) {
  966.             $this->updatedAt = new \DateTimeImmutable();
  967.         }
  968.     }
  969.     public function getIdentityMediaFile(): ?File
  970.     {
  971.         return $this->identityMediaFile;
  972.     }
  973.     public function setIdentityMedia(?string $media): self
  974.     {
  975.         $this->identityMedia $media;
  976.         return $this;
  977.     }
  978.     public function getIdentityMedia(): ?string
  979.     {
  980.         return $this->identityMedia;
  981.     }
  982.     public function getUserIdentityForms(): Collection
  983.     {
  984.         return $this->userIdentityForms;
  985.     }
  986.     public function getUserIdentityForm(User $user): ?UserIdentityForm
  987.     {
  988.         foreach ($this->userIdentityForms as $form) {
  989.             if ($form->getUser() === $user) {
  990.                 return $form;
  991.             }
  992.         }
  993.         return null;
  994.     }
  995.     public function addUserIdentityForm(UserIdentityForm $userIdentityForm): self
  996.     {
  997.         if (!$this->userIdentityForms->contains($userIdentityForm)) {
  998.             $this->userIdentityForms[] = $userIdentityForm;
  999.             $userIdentityForm->setBlogPost($this);
  1000.         }
  1001.         return $this;
  1002.     }
  1003.     public function removeUserIdentityForm(UserIdentityForm $userIdentityForm): self
  1004.     {
  1005.         if ($this->userIdentityForms->removeElement($userIdentityForm)) {
  1006.             if ($userIdentityForm->getBlogPost() === $this) {
  1007.                 $userIdentityForm->setBlogPost(null);
  1008.             }
  1009.         }
  1010.         return $this;
  1011.     }
  1012.     /**
  1013.      * @return Collection<int, Instance>
  1014.      */
  1015.     public function getInstances(): Collection
  1016.     {
  1017.         return $this->instances;
  1018.     }
  1019.     public function addInstance(Instance $instance): self
  1020.     {
  1021.         if (!$this->instances->contains($instance)) {
  1022.             $this->instances[] = $instance;
  1023.         }
  1024.         return $this;
  1025.     }
  1026.     public function removeInstance(Instance $instance): self
  1027.     {
  1028.         $this->instances->removeElement($instance);
  1029.         return $this;
  1030.     }
  1031.     public function getInstancesList(): string
  1032.     {
  1033.         return implode(', '$this->instances->toArray());
  1034.     }
  1035.     public function getDomain(): ?Domain
  1036.     {
  1037.         if ($this->domain && method_exists($this->domain'getId') && $this->domain->getId() === 0) {
  1038.             return null;
  1039.         }
  1040.         return $this->domain;
  1041.     }
  1042.     public function setDomain(?Domain $domain): self
  1043.     {
  1044.         $this->domain $domain;
  1045.         return $this;
  1046.     }
  1047.     public function getSubDomain(): ?SubDomain
  1048.     {
  1049.         if ($this->subDomain && method_exists($this->subDomain'getId') && $this->subDomain->getId() === 0) {
  1050.             return null;
  1051.         }
  1052.         return $this->subDomain;
  1053.     }
  1054.     public function setSubDomain(?SubDomain $subDomain): self
  1055.     {
  1056.         $this->subDomain $subDomain;
  1057.         return $this;
  1058.     }
  1059.     /**
  1060.      * Validation de la hiérarchie Domaine / Sous-domaine / Rubrique
  1061.      *
  1062.      * @Assert\Callback
  1063.      */
  1064.     public function validateHierarchy(ExecutionContextInterface $context): void
  1065.     {
  1066.         // 1) Domaine obligatoire : déjà couvert par Assert\NotNull + nullable=false
  1067.         // (on ne double pas le message ici)
  1068.         // 2) Si sous-domaine choisi => rubrique obligatoire
  1069.         if (null !== $this->getSubDomain() && null === $this->getBlogPostCategory()) {
  1070.             $context->buildViolation('La rubrique est obligatoire lorsque vous choisissez un sous-domaine.')
  1071.                 ->atPath('blogPostCategory')
  1072.                 ->addViolation();
  1073.         }
  1074.         // 3) Cohérence sous-domaine <-> domaine
  1075.         if (null !== $this->getSubDomain() && method_exists($this->getSubDomain(), 'getDomain')) {
  1076.             $sdDomain $this->getSubDomain()->getDomain();
  1077.             if (null !== $sdDomain && null !== $this->getDomain() && $sdDomain !== $this->getDomain()) {
  1078.                 $context->buildViolation('Le sous-domaine sélectionné ne correspond pas au domaine choisi.')
  1079.                     ->atPath('subDomain')
  1080.                     ->addViolation();
  1081.             }
  1082.         }
  1083.         // 4) Cohérence rubrique <-> sous-domaine + domaine
  1084.         if (null !== $this->getBlogPostCategory()) {
  1085.             // Rubrique => on doit pouvoir déduire son sous-domaine
  1086.             if (!method_exists($this->getBlogPostCategory(), 'getSubDomain')) {
  1087.                 $context->buildViolation('Configuration invalide : impossible de rattacher la rubrique à un sous-domaine.')
  1088.                     ->atPath('blogPostCategory')
  1089.                     ->addViolation();
  1090.                 return;
  1091.             }
  1092.             $catSubDomain $this->getBlogPostCategory()->getSubDomain();
  1093.             if (null === $catSubDomain) {
  1094.                 $context->buildViolation('La rubrique sélectionnée doit être rattachée à un sous-domaine.')
  1095.                     ->atPath('blogPostCategory')
  1096.                     ->addViolation();
  1097.                 return;
  1098.             }
  1099.             // Si un sous-domaine est sélectionné, il doit matcher celui de la rubrique
  1100.             if (null !== $this->getSubDomain() && $catSubDomain !== $this->getSubDomain()) {
  1101.                 $context->buildViolation('La rubrique sélectionnée ne correspond pas au sous-domaine choisi.')
  1102.                     ->atPath('blogPostCategory')
  1103.                     ->addViolation();
  1104.             }
  1105.             // Domaine doit être cohérent avec le domaine du sous-domaine de la rubrique
  1106.             if (method_exists($catSubDomain'getDomain')) {
  1107.                 $catDomain $catSubDomain->getDomain();
  1108.                 if (null !== $catDomain && null !== $this->getDomain() && $catDomain !== $this->getDomain()) {
  1109.                     $context->buildViolation('La rubrique sélectionnée ne correspond pas au domaine choisi.')
  1110.                         ->atPath('blogPostCategory')
  1111.                         ->addViolation();
  1112.                 }
  1113.             }
  1114.         }
  1115.     }
  1116.     public function isHome(): bool
  1117.     {
  1118.         return $this->isHome;
  1119.     }
  1120.     public function setIsHome(bool $isHome): self
  1121.     {
  1122.         $this->isHome $isHome;
  1123.         // Si on enlève Home, on nettoie la position
  1124.         if (!$isHome) {
  1125.             $this->homePosition null;
  1126.         }
  1127.         return $this;
  1128.     }
  1129.     public function getHomePosition(): ?int
  1130.     {
  1131.         return $this->homePosition;
  1132.     }
  1133.     public function setHomePosition(?int $homePosition): self
  1134.     {
  1135.         $this->homePosition $homePosition;
  1136.         return $this;
  1137.     }
  1138. }