src/Entity/Content.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Eventable\EventableTrait;
  4. use App\Entity\Sortable\Sortable;
  5. use App\Entity\Sortable\SortableInterface;
  6. use App\Repository\ContentRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11.  * @ORM\Entity(repositoryClass=ContentRepository::class)
  12.  */
  13. class Content implements SortableInterface
  14. {
  15.     use Sortable;
  16.     use EventableTrait;
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=128, unique=true)
  25.      */
  26.     private $code;
  27.     /**
  28.      * @ORM\Column(type="string", length=255, nullable=true)
  29.      */
  30.     private $title;
  31.     /**
  32.      * @ORM\Column(type="text", nullable=true)
  33.      */
  34.     private $body;
  35.     /**
  36.      * @ORM\ManyToMany(targetEntity=Image::class, cascade={"persist", "remove"}, orphanRemoval=true)
  37.      */
  38.     private $images;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private $style;
  43.     public function __construct()
  44.     {
  45.         $this->images = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getCode(): ?string
  52.     {
  53.         return $this->code;
  54.     }
  55.     public function setCode(string $code): self
  56.     {
  57.         $this->code $code;
  58.         return $this;
  59.     }
  60.     public function getBody(): ?string
  61.     {
  62.         return $this->body;
  63.     }
  64.     public function setBody(?string $body): self
  65.     {
  66.         $this->body $body;
  67.         return $this;
  68.     }
  69.     public function getTitle(): ?string
  70.     {
  71.         return $this->title;
  72.     }
  73.     public function setTitle(string $title): self
  74.     {
  75.         $this->title $title;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection<int, Image>
  80.      */
  81.     public function getImages(): Collection
  82.     {
  83.         return $this->images;
  84.     }
  85.     public function addImage(Image $image): self
  86.     {
  87.         if (!$this->images->contains($image)) {
  88.             $this->images[] = $image;
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeImage(Image $image): self
  93.     {
  94.         $this->images->removeElement($image);
  95.         return $this;
  96.     }
  97.     public function getStyle(): ?string
  98.     {
  99.         return $this->style;
  100.     }
  101.     public function setStyle(?string $style): self
  102.     {
  103.         $this->style $style;
  104.         return $this;
  105.     }
  106. }