<?php
namespace App\Entity;
use App\Repository\SponsorRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Gedmo\Translatable\Translatable;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\Ignore;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Translation\SponsorTranslation;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=SponsorRepository::class)
* @Gedmo\TranslationEntity(class="App\Entity\Translation\SponsorTranslation")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @Vich\Uploadable
*/
class Sponsor implements Translatable
{
use TimestampableEntity;
use SetTranslationsTrait;
public const FIELDS = [
'title',
'subtitle',
'content'
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups("sponsor:list", "sponsor:item")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Translatable
* @Groups("sponsor:list", "sponsor:item")
*/
private $title;
/**
* @var string
* @Ignore()
*/
private $titleEn;
/**
* @var string
* @Ignore()
*/
private $titleCa;
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Translatable
* @Groups("sponsor:list", "sponsor:item")
*/
private $subtitle;
/**
* @var string
* @Ignore()
*/
private $subtitleEn;
/**
* @var string
* @Ignore()
*
*/
private $subtitleCa;
/**
* @ORM\Column(type="text")
* @Gedmo\Translatable
* @Groups("sponsor:list", "sponsor:item")
*/
private $content;
/**
* @var string
* @Ignore()
*/
private $contentEn;
/**
* @var string
* @Ignore()
*/
private $contentCa;
/**
* @Assert\File(
* mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
* mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
* )
* @Vich\UploadableField(mapping="sponsor", fileNameProperty="imageName", size="imageSize")
* @var File|null
* @Ignore()
*/
private $imageFile;
/**
* @Gedmo\Locale
*/
private $locale;
/**
* @ORM\Column(type="string")
*
* @var string|null
* @Groups("sponsor:list", "sponsor:item")
*
*/
private $imageName;
/**
* @ORM\Column(type="integer")
*
* @var int|null
* @Ignore()
*/
private $imageSize;
/**
* @Assert\File(
* mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
* mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
* )
* @Vich\UploadableField(mapping="sponsor", fileNameProperty="logoName", size="logoSize")
* @var File|null
* @Ignore()
*/
private $logoFile;
/**
* @ORM\Column(type="string")
*
* @var string|null
* @Groups("sponsor:list", "sponsor:item")
*
*/
private $logoName;
/**
* @ORM\Column(type="integer")
*
* @var int|null
* @Ignore()
*/
private $logoSize;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups("sponsor:list", "sponsor:item")
*/
private $url;
/**
* @ORM\OneToMany(
* targetEntity="App\Entity\Translation\SponsorTranslation",
* mappedBy="object",
* cascade={"persist", "remove"}
* )
* @Ignore()
*/
private $translations;
/**
* @ORM\ManyToOne(targetEntity=SponsorCategory::class, inversedBy="sponsors")
* @ORM\JoinColumn(nullable=false)
* @Groups("sponsor:list", "sponsor:item")
*/
private $category;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var \DateTime|null
*/
protected $deletedAt;
/**
* @ORM\Column(type="integer",nullable=true, name="sort")
* @Groups("sponsor:list", "sponsor:item")
* @var int|null
*/
private $sort;
/**
* Set or clear the deleted at timestamp.
*
* @return self
*/
public function setDeletedAt(\DateTime $deletedAt = null)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get the deleted at timestamp value. Will return null if
* the entity has not been soft deleted.
*
* @return \DateTime|null
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* News constructor.
*/
public function __construct()
{
$this->translations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return mixed
*/
public function getTitleEn()
{
return $this->titleEn;
}
/**
* @param string|null $titleEn
*
* @return $this
*/
public function setTitleEn(?string $titleEn): self
{
$this->titleEn = $titleEn;
return $this;
}
/**
* @return mixed
*/
public function getTitleCa()
{
return $this->titleCa;
}
/**
* @param string|null $titleCa
*
* @return $this
*/
public function setTitleCa(?string $titleCa): self
{
$this->titleCa = $titleCa;
return $this;
}
public function setSubtitle(string $subtitle): self
{
$this->subtitle = $subtitle;
return $this;
}
/**
* @return mixed
*/
public function getSubtitleEn(): ?string
{
return $this->subtitleEn;
}
/**
* @param string|null $subtitleEn
*
* @return $this
*/
public function setSubtitleEn(?string $subtitleEn): self
{
$this->subtitleEn = $subtitleEn;
return $this;
}
/**
* @param string|null $subtitleCa
*
* @return $this
*/
public function setSubtitleCa(?string $subtitleCa): self
{
$this->subtitleCa = $subtitleCa;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
/**
* @return mixed
*/
public function getContentEn(): ?string
{
return $this->contentEn;
}
/**
* @param string|null $contentEn
*
* @return $this
*/
public function setContentEn(?string $contentEn): self
{
$this->contentEn = $contentEn;
return $this;
}
/**
* @return mixed
*/
public function getContentCa(): ?string
{
return $this->contentCa;
}
/**
* @param string|null $contentCa
*
* @return $this
*/
public function setContentCa(?string $contentCa): self
{
$this->contentCa = $contentCa;
return $this;
}
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
/**
* @param File|UploadedFile|null $imageFile
*/
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function setImageName(?string $imageName): void
{
$this->imageName = $imageName;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageSize(?int $imageSize): void
{
$this->imageSize = $imageSize;
}
public function getImageSize(): ?int
{
return $this->imageSize;
}
/**
* @param File|UploadedFile|null $logoFile
*/
public function setLogoFile(?File $logoFile = null): void
{
$this->logoFile = $logoFile;
if (null !== $logoFile) {
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getLogoFile(): ?File
{
return $this->logoFile;
}
public function setLogoName(?string $logoName): void
{
$this->logoName = $logoName;
}
public function getLogoName(): ?string
{
return $this->logoName;
}
public function setLogoSize(?int $logoSize): void
{
$this->logoSize = $logoSize;
}
public function getLogoSize(): ?int
{
return $this->logoSize;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getTranslations()
{
return $this->translations;
}
public function addTranslation(SponsorTranslation $t)
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
}
/**
* @return int|null
*/
public function getSort(): ?int
{
return $this->sort;
}
/**
* @param int|null $sort
* @return void
*/
public function setSort(?int $sort): void
{
$this->sort = $sort;
}
/**
* @return mixed
*/
public function getCategory()
{
return $this->category;
}
/**
* @param mixed $category
*/
public function setCategory($category): void
{
$this->category = $category;
}
public function getSubtitle(): ?string
{
return $this->subtitle;
}
/**
* @return mixed
*/
public function getSubtitleCa(): ?string
{
return $this->subtitleCa;
}
}