src/Entity/Inspiration.php line 26

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Annotation\DatabaseSubscriberClient;
  5. use App\Entity\Traits\EntitySEOTrait;
  6. use App\Entity\Traits\EntitySoftDeletableTrait;
  7. use App\Entity\Traits\EntityTimestampableTrait;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Gedmo\Mapping\Annotation\SoftDeleteable;
  13. use JMS\Serializer\Annotation\ExclusionPolicy;
  14. use JMS\Serializer\Annotation\Expose;
  15. use JMS\Serializer\Annotation\Groups;
  16. /**
  17.  * @ORM\Entity(repositoryClass="App\Repository\InspirationRepository")
  18.  * @SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
  19.  * @ExclusionPolicy("all")
  20.  * @DatabaseSubscriberClient()
  21.  */
  22. class Inspiration extends BaseDomain
  23. {
  24.     use EntityTimestampableTrait;
  25.     use EntitySoftDeletableTrait;
  26.     use EntitySEOTrait;
  27.     /**
  28.      * @ORM\Id()
  29.      * @ORM\GeneratedValue()
  30.      * @ORM\Column(type="integer")
  31.      */
  32.     private $id;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $title;
  37.     /**
  38.      * @var string $slug
  39.      *
  40.      * @Gedmo\Slug(fields={"title"})
  41.      * @ORM\Column(length=255, unique=true)
  42.      */
  43.     private $slug;
  44.     /**
  45.      * @ORM\Column(type="text", nullable=true)
  46.      */
  47.     private $shortDesc;
  48.     /**
  49.      * @ORM\Column(type="text", nullable=true)
  50.      */
  51.     private $content;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity="SonataMediaMedia")
  54.      */
  55.     private $media;
  56.     /**
  57.      * @ORM\Column(type="integer", nullable=true)
  58.      */
  59.     private $position;
  60.     /**
  61.      * @ORM\Column(type="boolean", options={"default": true})
  62.      */
  63.     private bool $isVisible true;
  64.     /**
  65.      * @ORM\OneToMany(targetEntity="InspirationGallery", mappedBy="inspiration",  cascade={"persist", "remove"}, orphanRemoval=true)
  66.      */
  67.     private $galleries;
  68.     public function __toString()
  69.     {
  70.         if ($this->title) {
  71.             return $this->title;
  72.         }
  73.         return '';
  74.     }
  75.     public function __construct()
  76.     {
  77.         $this->galleries = new ArrayCollection();
  78.         $this->position 1;
  79.     }
  80.     /**
  81.      * @return mixed
  82.      */
  83.     public function getId()
  84.     {
  85.         return $this->id;
  86.     }
  87.     /**
  88.      * @return mixed
  89.      */
  90.     public function getTitle()
  91.     {
  92.         return $this->title;
  93.     }
  94.     /**
  95.      * @param mixed $title
  96.      */
  97.     public function setTitle($title): void
  98.     {
  99.         $this->title $title;
  100.     }
  101.     /**
  102.      */
  103.     public function getSlug(): string
  104.     {
  105.         return $this->slug;
  106.     }
  107.     /**
  108.      */
  109.     public function setSlug(string $slug): void
  110.     {
  111.         $this->slug $slug;
  112.     }
  113.     /**
  114.      * @return mixed
  115.      */
  116.     public function getShortDesc()
  117.     {
  118.         return $this->shortDesc;
  119.     }
  120.     /**
  121.      * @param mixed $shortDesc
  122.      */
  123.     public function setShortDesc($shortDesc): void
  124.     {
  125.         $this->shortDesc $shortDesc;
  126.     }
  127.     /**
  128.      * @return mixed
  129.      */
  130.     public function getContent()
  131.     {
  132.         return $this->content;
  133.     }
  134.     /**
  135.      * @param mixed $content
  136.      */
  137.     public function setContent($content): void
  138.     {
  139.         $this->content $content;
  140.     }
  141.     /**
  142.      * @return mixed
  143.      */
  144.     public function getMedia()
  145.     {
  146.         return $this->media;
  147.     }
  148.     /**
  149.      * @param mixed $media
  150.      */
  151.     public function setMedia($media): void
  152.     {
  153.         $this->media $media;
  154.     }
  155.     /**
  156.      * @return mixed
  157.      */
  158.     public function getPosition()
  159.     {
  160.         return $this->position;
  161.     }
  162.     /**
  163.      * @param mixed $position
  164.      */
  165.     public function setPosition($position)
  166.     {
  167.         $this->position $position;
  168.     }
  169.     /**
  170.      * @return Collection|InspirationGallery[]
  171.      */
  172.     public function getGalleries()
  173.     {
  174.         return $this->galleries;
  175.     }
  176.     public function addGallery(InspirationGallery $gallery)
  177.     {
  178.         if (!$this->galleries->contains($gallery)) {
  179.             $this->galleries[] = $gallery;
  180.             $gallery->setInspiration($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeGallery(InspirationGallery $gallery)
  185.     {
  186.         if ($this->galleries->removeElement($gallery)) {
  187.             $gallery->setInspiration(null);
  188.         }
  189.         return $this;
  190.     }
  191.     public function isVisible(): bool
  192.     {
  193.         return $this->isVisible;
  194.     }
  195.     public function setIsVisible(bool $isVisible): self
  196.     {
  197.         $this->isVisible $isVisible;
  198.         return $this;
  199.     }
  200. }