src/Entity/PlacementImage.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClass\App\Repository\PlacementImageRepository::class)]
  7. class PlacementImage implements \Stringable
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private int $id;
  13.     #[ORM\Column(type'string'length255nullabletrue)]
  14.     private ?string $namenull;
  15.     #[ORM\OneToMany(targetEntity\App\Entity\Post::class, mappedBy'position_image')]
  16.     private mixed $posts;
  17.     #[ORM\OneToMany(targetEntityPageAccueil::class, mappedBy'image_enavant_placement')]
  18.     private mixed $pageAccueils;
  19.     public function __construct()
  20.     {
  21.         $this->posts = new ArrayCollection();
  22.         $this->pageAccueils = new ArrayCollection();
  23.     }
  24.     public function __toString(): string
  25.     {
  26.         return (string) $this->name;
  27.     }
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getName(): ?string
  33.     {
  34.         return $this->name;
  35.     }
  36.     public function setName(?string $name): self
  37.     {
  38.         $this->name $name;
  39.         return $this;
  40.     }
  41.     /**
  42.      * @return Collection|Post[]
  43.      */
  44.     public function getPosts(): Collection
  45.     {
  46.         return $this->posts;
  47.     }
  48.     public function addPost(Post $post): self
  49.     {
  50.         if (!$this->posts->contains($post)) {
  51.             $this->posts[] = $post;
  52.             $post->setPositionImage($this);
  53.         }
  54.         return $this;
  55.     }
  56.     public function removePost(Post $post): self
  57.     {
  58.         if ($this->posts->contains($post)) {
  59.             $this->posts->removeElement($post);
  60.             // set the owning side to null (unless already changed)
  61.             if ($post->getPositionImage() === $this) {
  62.                 $post->setPositionImage(null);
  63.             }
  64.         }
  65.         return $this;
  66.     }
  67.     /**
  68.      * @return Collection|PageAccueil[]
  69.      */
  70.     public function getPageAccueils(): Collection
  71.     {
  72.         return $this->pageAccueils;
  73.     }
  74.     public function addPageAccueil(PageAccueil $pageAccueil): self
  75.     {
  76.         if (!$this->pageAccueils->contains($pageAccueil)) {
  77.             $this->pageAccueils[] = $pageAccueil;
  78.             $pageAccueil->setImageEnavantPlacement($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removePageAccueil(PageAccueil $pageAccueil): self
  83.     {
  84.         if ($this->pageAccueils->removeElement($pageAccueil)) {
  85.             // set the owning side to null (unless already changed)
  86.             if ($pageAccueil->getImageEnavantPlacement() === $this) {
  87.                 $pageAccueil->setImageEnavantPlacement(null);
  88.             }
  89.         }
  90.         return $this;
  91.     }
  92. }