src/Entity/Landingpage.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\LandingpageRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\UX\Turbo\Attribute\Broadcast;
  9. #[ORM\Entity(repositoryClassLandingpageRepository::class)]
  10. #[ApiResource]
  11. #[Broadcast]
  12. class Landingpage
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $name null;
  20.     #[ORM\ManyToOne(inversedBy'landingpages')]
  21.     private ?Portal $portal null;
  22.     #[ORM\OneToMany(mappedBy'landingpage'targetEntityLandingpageElement::class, cascade: ['persist'])]
  23.     private Collection $landingpageElements;
  24.     public function __construct()
  25.     {
  26.         $this->landingpageElements = new ArrayCollection();
  27.         $this->addLandingpageElement(new LandingpageElement());
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getName(): ?string
  34.     {
  35.         return $this->name;
  36.     }
  37.     public function setName(string $name): self
  38.     {
  39.         $this->name $name;
  40.         return $this;
  41.     }
  42.     public function getPortal(): ?Portal
  43.     {
  44.         return $this->portal;
  45.     }
  46.     public function setPortal(?Portal $portal): self
  47.     {
  48.         $this->portal $portal;
  49.         return $this;
  50.     }
  51.     /**
  52.      * @return Collection<int, LandingpageElement>
  53.      */
  54.     public function getLandingpageElements(): Collection
  55.     {
  56.         return $this->landingpageElements;
  57.     }
  58.     public function addLandingpageElement(LandingpageElement $landingpageElement): self
  59.     {
  60.         if (!$this->landingpageElements->contains($landingpageElement)) {
  61.             $this->landingpageElements->add($landingpageElement);
  62.             $landingpageElement->setLandingpage($this);
  63.         }
  64.         return $this;
  65.     }
  66.     public function removeLandingpageElement(LandingpageElement $landingpageElement): self
  67.     {
  68.         if ($this->landingpageElements->removeElement($landingpageElement)) {
  69.             // set the owning side to null (unless already changed)
  70.             if ($landingpageElement->getLandingpage() === $this) {
  71.                 $landingpageElement->setLandingpage(null);
  72.             }
  73.         }
  74.         return $this;
  75.     }
  76. }