<?php
namespace App\Entity;
use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @ORM\Entity
* @ORM\Table(name="banners")
*/
class Banners implements BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use SoftDeletableTrait;
const TYPE_BIG = 'big_banner';
const TYPE_SMALL = 'small_banner';
const TYPE_LANDING_PAGE = 'landing_page_banner';
const TYPE_PROMOTION_BANNER = 'promotion_banner';
static public function getBannersType(TranslatorInterface $translator) {
return [
$translator->trans(self::TYPE_BIG, [], 'admin') => self::TYPE_BIG,
$translator->trans(self::TYPE_SMALL, [], 'admin') => self::TYPE_SMALL,
$translator->trans(self::TYPE_LANDING_PAGE, [], 'admin') => self::TYPE_LANDING_PAGE,
];
}
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="banner_type", type="string", length=255, nullable=true)
*/
private $type;
/**
* @Doctrine\ORM\Mapping\Column(type="boolean", nullable=true)
*/
protected $visible = true;
/**
* @Doctrine\ORM\Mapping\Column(type="boolean", nullable=true, options={"default"=1})
*/
protected $visibleInPromotions = true;
/**
* @var string
*
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*/
private $url;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Language")
* @ORM\JoinColumn(name="language", referencedColumnName="id")
*/
protected $language;
/**
* @var string
*
* @ORM\Column(name="position", type="string", length=255, nullable=true)
*/
private $position;
/**
* @var string
*
* @ORM\Column(name="color", type="string", length=255, nullable=true)
*/
private $color;
/**
* @var string
*
* @ORM\Column(name="additional_text", type="string", length=255, nullable=true)
*/
private $additionalText;
/**
* @var string
*
* @ORM\Column(name="button_color", type="string", length=255, nullable=true)
*/
private $buttonColor;
/**
* @var string
*
* @ORM\Column(name="button_text_color", type="string", length=255, nullable=true)
*/
private $buttonTextColor;
/**
* @var string
*
* @ORM\Column(name="campaign_text_color", type="string", length=255, nullable=true)
*/
private $campaignTextColor;
/**
* @var string
*
* @ORM\Column(name="button_text", type="string", length=255, nullable=true)
*/
private $buttonText;
/**
* @var string
*
* @ORM\Column(name="bottom_button_text", type="string", length=255, nullable=true)
*/
private $bottomButtonText;
/**
* @var string
*
* @ORM\Column(name="bottom_button_text_color", type="string", length=255, nullable=true)
*/
private $bottomButtonTextColor;
/**
* @var string
*
* @ORM\Column(name="bottom_button_color", type="string", length=255, nullable=true)
*/
private $bottomButtonColor;
/**
* @var string
*
* @ORM\Column(name="bottom_background_color", type="string", length=255, nullable=true)
*/
private $bottomBackgroundColor;
/**
* @return bool
*/
public function isVisibleInPromotions()
{
return $this->visibleInPromotions;
}
/**
* @param bool $visibleInPromotions
*/
public function setVisibleInPromotions($visibleInPromotions)
{
$this->visibleInPromotions = $visibleInPromotions;
}
/**
* @var string
*
* @ORM\Column(name="bottom_text_color", type="string", length=255, nullable=true)
*/
private $bottomTextColor;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return ProductProducer
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
*
* note This is not a mapped field of entity metadata, just a simple property.
*
* @var File $imageFile
*/
protected $imageFile;
/**
* @ORM\Column(type="string", length=255, name="image_name", nullable=true)
* @var string $imageName
*/
protected $imageName;
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
if ($image) {
$fileName = md5(uniqid()).'.'.$image->guessExtension();
// Move the file to the directory where brochures are stored
$brochuresDir = getcwd().'/images/important/';
$image->move($brochuresDir, $fileName);
// Update the 'brochure' property to store the PDF file name
// instead of its contents
$this->setImageName($fileName);
$this->updatedAt = new \DateTime('now');
}
return $this;
}
/**
* @return File
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param string $imageName
*/
public function setImageName($imageName)
{
$this->imageName = $imageName;
}
/**
* @return string
*/
public function getImageName()
{
return $this->imageName;
}
public function getVisible(): ?bool
{
return $this->visible;
}
public function setVisible(?bool $visible): self
{
$this->visible = $visible;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(?string $position): self
{
$this->position = $position;
return $this;
}
public function getLanguage(): ?Language
{
return $this->language;
}
public function setLanguage(?Language $language): self
{
$this->language = $language;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return string
*/
public function getColor(): ?string
{
return $this->color;
}
/**
* @param string $color
*/
public function setColor($color): void
{
$this->color = $color;
}
/**
* @return string
*/
public function getAdditionalText(): ?string
{
return $this->additionalText;
}
/**
* @param $additionalText
*/
public function setAdditionalText($additionalText): void
{
$this->additionalText = $additionalText;
}
/**
* @return string
*/
public function getButtonColor(): ?string
{
return $this->buttonColor;
}
/**
* @param $buttonColor
*/
public function setButtonColor($buttonColor): void
{
$this->buttonColor = $buttonColor;
}
/**
* @return string
*/
public function getButtonText(): ?string
{
return $this->buttonText;
}
/**
* @param $buttonText
*/
public function setButtonText($buttonText): void
{
$this->buttonText = $buttonText;
}
/**
* @return string
*/
public function getButtonTextColor()
{
return $this->buttonTextColor;
}
/**
* @param string $buttonTextColor
*/
public function setButtonTextColor($buttonTextColor)
{
$this->buttonTextColor = $buttonTextColor;
}
/**
* @return string
*/
public function getCampaignTextColor()
{
return $this->campaignTextColor;
}
/**
* @param string $campaignTextColor
*/
public function setCampaignTextColor($campaignTextColor)
{
$this->campaignTextColor = $campaignTextColor;
}
/**
* @return string
*/
public function getBottomButtonText()
{
return $this->bottomButtonText;
}
/**
* @param string $bottomButtonText
*/
public function setBottomButtonText($bottomButtonText): void
{
$this->bottomButtonText = $bottomButtonText;
}
/**
* @return string
*/
public function getBottomButtonTextColor()
{
return $this->bottomButtonTextColor;
}
/**
* @param $bottomButtonTextColor
*/
public function setBottomButtonTextColor($bottomButtonTextColor): void
{
$this->bottomButtonTextColor = $bottomButtonTextColor;
}
/**
* @return string
*/
public function getBottomButtonColor()
{
return $this->bottomButtonColor;
}
/**
* @param $bottomButtonColor
*/
public function setBottomButtonColor($bottomButtonColor): void
{
$this->bottomButtonColor = $bottomButtonColor;
}
/**
* @return string
*/
public function getBottomBackgroundColor()
{
return $this->bottomBackgroundColor;
}
/**
* @param $bottomBackgroundColor
*/
public function setBottomBackgroundColor($bottomBackgroundColor): void
{
$this->bottomBackgroundColor = $bottomBackgroundColor;
}
/**
* @return string
*/
public function getBottomTextColor()
{
return $this->bottomTextColor;
}
/**
* @param string $bottomTextColor
*/
public function setBottomTextColor($bottomTextColor): void
{
$this->bottomTextColor = $bottomTextColor;
}
public function getVisibleInPromotions(): ?bool
{
return $this->visibleInPromotions;
}
}