<?php
namespace App\Entity;
use App\Repository\ModulePageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=ModulePageRepository::class)
* @Vich\Uploadable()
* @ORM\HasLifecycleCallbacks
*/
class ModulePage extends SeoEntity
{
const TARIFFS = [
'StartUp' => 0,
'Business' => 1,
'Pro' => 2,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $capabilityTitle;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $capabilityText;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $configureTitle;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $configureText;
/**
* @ORM\Column(type="json")
*/
private $tariffs = [];
/**
* @ORM\Column(type="text", nullable=true)
*/
private $featureText;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $featureImage;
/**
* @var File|null
* @Vich\UploadableField(mapping="module", fileNameProperty="featureImage")
* @Assert\File(
* maxSize= "200k"
* )
*/
private $featureImageFile;
/**
* @ORM\Column(type="datetime_immutable", options={"default":"CURRENT_TIMESTAMP"})
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTimeInterface|null
*/
private $updatedAt;
/**
* @ORM\OneToMany(targetEntity=ModuleAttachment::class, mappedBy="module", cascade={"persist","refresh","remove"})
*/
private $attachments;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $featureBtnText = 'Попробовать бесплатно';
/**
* @ORM\Column(type="boolean")
*/
private $active = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $featureYouTube;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $pos = 500;
public function getId(): ?int
{
return $this->id;
}
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
$this->attachments = new ArrayCollection();
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getCapabilityText(): ?string
{
return $this->capabilityText;
}
public function setCapabilityText(?string $capabilityText): self
{
$this->capabilityText = $capabilityText;
return $this;
}
public function getConfigureText(): ?string
{
return $this->configureText;
}
public function setConfigureText(?string $configureText): self
{
$this->configureText = $configureText;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return mixed
*/
public function getCapabilityTitle()
{
return $this->capabilityTitle;
}
/**
* @param mixed $capabilityTitle
* @return ModulePage
*/
public function setCapabilityTitle($capabilityTitle): self
{
$this->capabilityTitle = $capabilityTitle;
return $this;
}
public function getFeatureText(): ?string
{
return $this->featureText;
}
public function setFeatureText(?string $featureText): self
{
$this->featureText = $featureText;
return $this;
}
public function getFeatureImage(): ?string
{
return $this->featureImage;
}
public function setFeatureImage(?string $featureImage): self
{
$this->featureImage = $featureImage;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return File|null
*/
public function getFeatureImageFile(): ?File
{
return $this->featureImageFile;
}
/**
* @param File|null $featureImageFile
*/
public function setFeatureImageFile(?File $imageFile): self
{
$this->featureImageFile = $imageFile;
if ($imageFile) {
$this->updatedAt = new \DateTimeImmutable();
}
return $this;
}
/**
* @return string|null
*/
public function getConfigureTitle(): ?string
{
return $this->configureTitle;
}
/**
* @param string|null $configureTitle
*/
public function setConfigureTitle(?string $configureTitle): self
{
$this->configureTitle = $configureTitle;
return $this;
}
/**
* @return array
*/
public function getTariffs(): array
{
return $this->tariffs;
}
/**
* @param array $tariffs
*/
public function setTariffs(array $tariffs): self
{
$this->tariffs = $tariffs;
return $this;
}
/**
* @return \DateTimeInterface|null
*/
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
/**
* @return Collection|ModuleAttachment[]
*/
public function getAttachments(): Collection
{
return $this->attachments;
}
public function addAttachment(ModuleAttachment $attachment): self
{
if (!$this->attachments->contains($attachment)) {
$this->attachments[] = $attachment;
$attachment->setModule($this);
}
return $this;
}
public function removeAttachment(ModuleAttachment $attachment): self
{
if ($this->attachments->removeElement($attachment)) {
// set the owning side to null (unless already changed)
if ($attachment->getModule() === $this) {
$attachment->setModule(null);
}
}
return $this;
}
public function getFeatureBtnText(): ?string
{
return $this->featureBtnText;
}
public function setFeatureBtnText(?string $featureBtnText): self
{
$this->featureBtnText = $featureBtnText;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getFeatureYouTube(): ?string
{
return $this->featureYouTube;
}
public function setFeatureYouTube(?string $featureYouTube): self
{
$this->featureYouTube = $featureYouTube;
return $this;
}
public function getPos(): ?int
{
return $this->pos;
}
public function setPos(?int $pos): self
{
$this->pos = $pos;
return $this;
}
/**
* Триггер только на обновление.
* @ORM\PreUpdate
*/
public function onPreUpdate()
{
$this->updatedAt = new \DateTimeImmutable();
}
}