src/Entity/OSEntity.php line 17
- <?php
- namespace App\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\ORM\Mapping\MappedSuperclass;
- use Symfony\Component\HttpFoundation\File\File as SymfonyFile;
- use Symfony\Component\Validator\Constraints as Assert;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use OlaSoft\Common;
- /**
- * @ORM\MappedSuperclass()
- * @ORM\HasLifecycleCallbacks()
- */
- class OSEntity implements \Serializable
- {
- /**
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORM\Column(name="title", type="string", length=255,nullable=true)
- */
- protected $title;
- /**
- * @ORM\Column(name="description", type="text", nullable=true)
- */
- protected $description;
- /**
- * @ORM\Column(name="content", type="text",nullable=true)
- */
- protected $content;
- /**
- * @ORM\OneToOne(targetEntity="App\Entity\Picture", cascade={"persist","remove"}, orphanRemoval=true, fetch="EAGER")
- * @ORM\JoinColumn(nullable=true)
- */
- protected $banner;
- /**
- * @ORM\Column(name="slug", type="string", length=255,nullable=true)
- */
- protected $slug;
- /**
- * @ORM\ManyToMany(targetEntity=Tags::class)
- */
- protected $tags;
- /**
- * @ORM\ManyToOne(targetEntity=Sectors::class)
- * @ORM\JoinColumn(nullable=true)
- */
- protected $sector;
- /**
- * @ORM\Column(type="datetime", nullable=true)
- */
- protected $date;
- /**
- * @ORM\Column(name="createdAt", type="datetime", nullable=true)
- */
- protected $createdAt;
- /**
- * @ORM\ManyToOne(targetEntity="App\Entity\Users", fetch="EAGER")
- * @ORM\JoinColumn(nullable=true)
- */
- protected $user;
- /**
- * @ORM\Column(name="lastUpdate", type="datetime", nullable=true)
- */
- protected $lastUpdate;
- /**
- * @ORM\ManyToOne(targetEntity="App\Entity\Users")
- * @ORM\JoinColumn(name="updatedBy",nullable=true)
- */
- protected $updatedBy;
- /**
- * @ORM\Column(name="isEnabled", type="boolean", nullable=true)
- */
- protected $isEnabled;
- public function __construct()
- {
- $this->isEnabled = false;
- $this->createdAt = new \DateTime;
- $this->date = new \DateTime;
- $this->tags = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function __toString(){
- return $this->getTitle() ?? "";
- }
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->title,
- $this->content,
- ));
- }
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->title,
- $this->content,
- ) = unserialize($serialized);
- }
- public function getTitle(): ?string
- {
- return $this->title;
- }
- public function setTitle(?string $title): self
- {
- $this->title = $title;
- return $this;
- }
- public function getDescription(): ?string
- {
- return $this->description;
- }
- public function setDescription(?string $description): self
- {
- $this->description = $description;
- return $this;
- }
- public function getContent(): ?string
- {
- return $this->content;
- }
- public function setContent(?string $content): self
- {
- $this->content = $content;
- return $this;
- }
- public function getSlug(): ?string
- {
- return $this->slug;
- }
- public function setSlug(?string $slug): self
- {
- $this->slug = $slug;
- return $this;
- }
- /**
- * @ORM\PrePersist()
- */
- public function setSlugOnPersist(){
- $this->setSlug(Common::slug($this->getTitle()));
- }
- /**
- * @ORM\PreUpdate()
- */
- public function setSlugOnUpdate(){
- $this->setSlug(Common::slug($this->getTitle()));
- }
- public function getDate(): ?\DateTimeInterface
- {
- return $this->date;
- }
- public function setDate(?\DateTimeInterface $date): self
- {
- $this->date = $date;
- return $this;
- }
- public function getCreatedAt(): ?\DateTimeInterface
- {
- return $this->createdAt;
- }
- public function setCreatedAt(\DateTimeInterface $date): self
- {
- $this->createdAt = $date;
- return $this;
- }
- public function isEnabled(): ?bool
- {
- return $this->isEnabled;
- }
- public function getIsEnabled(): ?bool
- {
- return $this->isEnabled;
- }
- public function setIsEnabled(?bool $isEnabled): self
- {
- $this->isEnabled = $isEnabled;
- return $this;
- }
- public function getBanner(): ?Picture
- {
- return $this->banner;
- }
- public function setBanner(?Picture $banner): self
- {
- if($banner->getTarget()){
- $this->banner = $banner;
- $this->banner->setDir('upload/images/banners/');
- $this->banner->setThumbnailDir('upload/thumbnails/banners/');
- }
- return $this;
- }
- public function getUser(): ?Users
- {
- return $this->user;
- }
- public function setUser(?Users $user): self
- {
- $this->user = $user;
- return $this;
- }
- public function getLastUpdate(): ?\DateTimeInterface
- {
- return $this->lastUpdate;
- }
- public function setLastUpdate(\DateTimeInterface $lastUpdate): self
- {
- $this->lastUpdate = $lastUpdate;
- return $this;
- }
- public function getUpdatedBy(): ?Users
- {
- return $this->updatedBy;
- }
- public function setUpdatedBy(?Users $updatedBy): self
- {
- $this->updatedBy = $updatedBy;
- return $this;
- }
- public function getTags(): Collection
- {
- return $this->tags;
- }
- public function addTag(Tags $tag): self
- {
- if (!$this->tags->contains($tag)) {
- $this->tags[] = $tag;
- }
- return $this;
- }
- public function removeTag(Tags $tag): self
- {
- $this->tags->removeElement($tag);
- return $this;
- }
- public function getSector(): ?Sectors
- {
- return $this->sector;
- }
- public function setSector(?Sectors $sector): self
- {
- $this->sector = $sector;
- return $this;
- }
- }