src/Entity/FaqTheme.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FaqThemeRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClassFaqThemeRepository::class)]
  9. class FaqTheme
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $title null;
  17.     #[ORM\OneToMany(mappedBy'faqTheme'targetEntityFaq::class, cascade: ['persist''remove']),
  18.         Assert\NotBlank(),
  19.         Assert\Valid()
  20.     ]
  21.     private $faqs ;
  22.     public function __construct()
  23.     {
  24.         $this->faqs = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getTitle(): ?string
  31.     {
  32.         return $this->title;
  33.     }
  34.     public function setTitle(string $title): self
  35.     {
  36.         $this->title $title;
  37.         return $this;
  38.     }
  39.     /**
  40.      * @return Collection<int, Faq>
  41.      */
  42.     public function getFaqs(): Collection
  43.     {
  44.         return $this->faqs;
  45.     }
  46.     public function addFaq(Faq $faq): self
  47.     {
  48.         if (!$this->faqs->contains($faq)) {
  49.             $this->faqs->add($faq);
  50.             $faq->setFaqTheme($this);
  51.         }
  52.         return $this;
  53.     }
  54.     public function removeFaq(Faq $faq): self
  55.     {
  56.         if ($this->faqs->removeElement($faq)) {
  57.             // set the owning side to null (unless already changed)
  58.             if ($faq->getFaqTheme() === $this) {
  59.                 $faq->setFaqTheme(null);
  60.             }
  61.         }
  62.         return $this;
  63.     }
  64. }