src/Entity/Banners.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  6. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  7. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Symfony\Component\HttpFoundation\File\UploadedFile;
  12. use Symfony\Component\HttpFoundation\File\File;
  13. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  14. use Symfony\Contracts\Translation\TranslatorInterface;
  15. /**
  16.  * @ORM\Entity
  17.  * @ORM\Table(name="banners")
  18.  */
  19. class Banners implements BlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  20.     use BlameableTrait;
  21.     use TimestampableTrait;
  22.     
  23.     use SoftDeletableTrait;
  24.     
  25. const TYPE_BIG 'big_banner';
  26.     const TYPE_SMALL 'small_banner';
  27.     const TYPE_LANDING_PAGE 'landing_page_banner';
  28.     const TYPE_PROMOTION_BANNER 'promotion_banner';
  29.     static public function getBannersType(TranslatorInterface $translator) {
  30.         return [
  31.             $translator->trans(self::TYPE_BIG, [], 'admin') => self::TYPE_BIG,
  32.             $translator->trans(self::TYPE_SMALL, [], 'admin') => self::TYPE_SMALL,
  33.             $translator->trans(self::TYPE_LANDING_PAGE, [], 'admin') => self::TYPE_LANDING_PAGE,
  34.         ];
  35.     }
  36.     /**
  37.      * @ORM\Id
  38.      * @ORM\Column(type="integer")
  39.      * @ORM\GeneratedValue(strategy="AUTO")
  40.      */
  41.     protected $id;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(name="name", type="string", length=255, nullable=true)
  46.      */
  47.     private $name;
  48.     /**
  49.      * @var string
  50.      *
  51.      * @ORM\Column(name="title", type="string", length=255, nullable=true)
  52.      */
  53.     private $title;
  54.     /**
  55.      * @var string
  56.      *
  57.      * @ORM\Column(name="banner_type", type="string", length=255, nullable=true)
  58.      */
  59.     private $type;
  60.     /**
  61.      * @Doctrine\ORM\Mapping\Column(type="boolean", nullable=true)
  62.      */
  63.     protected $visible true;
  64.     /**
  65.      * @Doctrine\ORM\Mapping\Column(type="boolean", nullable=true, options={"default"=1})
  66.      */
  67.     protected $visibleInPromotions true;
  68.     /**
  69.      * @var string
  70.      *
  71.      * @ORM\Column(name="url", type="string", length=255, nullable=true)
  72.      */
  73.     private $url;
  74.     /**
  75.      * @ORM\ManyToOne(targetEntity="App\Entity\Language")
  76.      * @ORM\JoinColumn(name="language", referencedColumnName="id")
  77.      */
  78.     protected $language;
  79.     /**
  80.      * @var string
  81.      *
  82.      * @ORM\Column(name="position", type="string", length=255, nullable=true)
  83.      */
  84.     private $position;
  85.     /**
  86.      * @var string
  87.      *
  88.      * @ORM\Column(name="color", type="string", length=255, nullable=true)
  89.      */
  90.     private $color;
  91.     /**
  92.      * @var string
  93.      *
  94.      * @ORM\Column(name="additional_text", type="string", length=255, nullable=true)
  95.      */
  96.     private $additionalText;
  97.     /**
  98.      * @var string
  99.      *
  100.      * @ORM\Column(name="button_color", type="string", length=255, nullable=true)
  101.      */
  102.     private $buttonColor;
  103.     /**
  104.      * @var string
  105.      *
  106.      * @ORM\Column(name="button_text_color", type="string", length=255, nullable=true)
  107.      */
  108.     private $buttonTextColor;
  109.     /**
  110.      * @var string
  111.      *
  112.      * @ORM\Column(name="campaign_text_color", type="string", length=255, nullable=true)
  113.      */
  114.     private $campaignTextColor;
  115.     /**
  116.      * @var string
  117.      *
  118.      * @ORM\Column(name="button_text", type="string", length=255, nullable=true)
  119.      */
  120.     private $buttonText;
  121.     /**
  122.      * @var string
  123.      *
  124.      * @ORM\Column(name="bottom_button_text", type="string", length=255, nullable=true)
  125.      */
  126.     private $bottomButtonText;
  127.     /**
  128.      * @var string
  129.      *
  130.      * @ORM\Column(name="bottom_button_text_color", type="string", length=255, nullable=true)
  131.      */
  132.     private $bottomButtonTextColor;
  133.     /**
  134.      * @var string
  135.      *
  136.      * @ORM\Column(name="bottom_button_color", type="string", length=255, nullable=true)
  137.      */
  138.     private $bottomButtonColor;
  139.     /**
  140.      * @var string
  141.      *
  142.      * @ORM\Column(name="bottom_background_color", type="string", length=255, nullable=true)
  143.      */
  144.     private $bottomBackgroundColor;
  145.     /**
  146.      * @return bool
  147.      */
  148.     public function isVisibleInPromotions()
  149.     {
  150.         return $this->visibleInPromotions;
  151.     }
  152.     /**
  153.      * @param bool $visibleInPromotions
  154.      */
  155.     public function setVisibleInPromotions($visibleInPromotions)
  156.     {
  157.         $this->visibleInPromotions $visibleInPromotions;
  158.     }
  159.     /**
  160.      * @var string
  161.      *
  162.      * @ORM\Column(name="bottom_text_color", type="string", length=255, nullable=true)
  163.      */
  164.     private $bottomTextColor;
  165.     
  166.     /**
  167.      * Get id
  168.      *
  169.      * @return integer
  170.      */
  171.     public function getId()
  172.     {
  173.         return $this->id;
  174.     }
  175.     /**
  176.      * Set name
  177.      *
  178.      * @param string $name
  179.      *
  180.      * @return ProductProducer
  181.      */
  182.     public function setName($name)
  183.     {
  184.         $this->name $name;
  185.         return $this;
  186.     }
  187.     /**
  188.      * Get name
  189.      *
  190.      * @return string
  191.      */
  192.     public function getName()
  193.     {
  194.         return $this->name;
  195.     }
  196.     /**
  197.      *
  198.      * note This is not a mapped field of entity metadata, just a simple property.
  199.      *
  200.      * @var File $imageFile
  201.      */
  202.     protected $imageFile;
  203.     /**
  204.      * @ORM\Column(type="string", length=255, name="image_name", nullable=true)
  205.      * @var string $imageName
  206.      */
  207.     protected $imageName;
  208.     public function setImageFile(File $image null)
  209.     {
  210.         $this->imageFile $image;
  211.         if ($image) {
  212.             $fileName md5(uniqid()).'.'.$image->guessExtension();
  213.             // Move the file to the directory where brochures are stored
  214.             $brochuresDir getcwd().'/images/important/';
  215.             $image->move($brochuresDir$fileName);
  216.             // Update the 'brochure' property to store the PDF file name
  217.             // instead of its contents
  218.             $this->setImageName($fileName);
  219.             $this->updatedAt = new \DateTime('now');
  220.         }
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return File
  225.      */
  226.     public function getImageFile()
  227.     {
  228.         return $this->imageFile;
  229.     }
  230.     /**
  231.      * @param string $imageName
  232.      */
  233.     public function setImageName($imageName)
  234.     {
  235.         $this->imageName $imageName;
  236.     }
  237.     /**
  238.      * @return string
  239.      */
  240.     public function getImageName()
  241.     {
  242.         return $this->imageName;
  243.     }
  244.     public function getVisible(): ?bool
  245.     {
  246.         return $this->visible;
  247.     }
  248.     public function setVisible(?bool $visible): self
  249.     {
  250.         $this->visible $visible;
  251.         return $this;
  252.     }
  253.     public function getUrl(): ?string
  254.     {
  255.         return $this->url;
  256.     }
  257.     public function setUrl(?string $url): self
  258.     {
  259.         $this->url $url;
  260.         return $this;
  261.     }
  262.     public function getPosition(): ?string
  263.     {
  264.         return $this->position;
  265.     }
  266.     public function setPosition(?string $position): self
  267.     {
  268.         $this->position $position;
  269.         return $this;
  270.     }
  271.     public function getLanguage(): ?Language
  272.     {
  273.         return $this->language;
  274.     }
  275.     public function setLanguage(?Language $language): self
  276.     {
  277.         $this->language $language;
  278.         return $this;
  279.     }
  280.     public function getType(): ?string
  281.     {
  282.         return $this->type;
  283.     }
  284.     public function setType(?string $type): self
  285.     {
  286.         $this->type $type;
  287.         return $this;
  288.     }
  289.     public function getTitle(): ?string
  290.     {
  291.         return $this->title;
  292.     }
  293.     public function setTitle(?string $title): self
  294.     {
  295.         $this->title $title;
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return string
  300.      */
  301.     public function getColor(): ?string
  302.     {
  303.         return $this->color;
  304.     }
  305.     /**
  306.      * @param string $color
  307.      */
  308.     public function setColor($color): void
  309.     {
  310.         $this->color $color;
  311.     }
  312.     /**
  313.      * @return string
  314.      */
  315.     public function getAdditionalText(): ?string
  316.     {
  317.         return $this->additionalText;
  318.     }
  319.     /**
  320.      * @param $additionalText
  321.      */
  322.     public function setAdditionalText($additionalText): void
  323.     {
  324.         $this->additionalText $additionalText;
  325.     }
  326.     /**
  327.      * @return string
  328.      */
  329.     public function getButtonColor(): ?string
  330.     {
  331.         return $this->buttonColor;
  332.     }
  333.     /**
  334.      * @param $buttonColor
  335.      */
  336.     public function setButtonColor($buttonColor): void
  337.     {
  338.         $this->buttonColor $buttonColor;
  339.     }
  340.     /**
  341.      * @return string
  342.      */
  343.     public function getButtonText(): ?string
  344.     {
  345.         return $this->buttonText;
  346.     }
  347.     /**
  348.      * @param $buttonText
  349.      */
  350.     public function setButtonText($buttonText): void
  351.     {
  352.         $this->buttonText $buttonText;
  353.     }
  354.     /**
  355.      * @return string
  356.      */
  357.     public function getButtonTextColor()
  358.     {
  359.         return $this->buttonTextColor;
  360.     }
  361.     /**
  362.      * @param string $buttonTextColor
  363.      */
  364.     public function setButtonTextColor($buttonTextColor)
  365.     {
  366.         $this->buttonTextColor $buttonTextColor;
  367.     }
  368.     /**
  369.      * @return string
  370.      */
  371.     public function getCampaignTextColor()
  372.     {
  373.         return $this->campaignTextColor;
  374.     }
  375.     /**
  376.      * @param string $campaignTextColor
  377.      */
  378.     public function setCampaignTextColor($campaignTextColor)
  379.     {
  380.         $this->campaignTextColor $campaignTextColor;
  381.     }
  382.     /**
  383.      * @return string
  384.      */
  385.     public function getBottomButtonText()
  386.     {
  387.         return $this->bottomButtonText;
  388.     }
  389.     /**
  390.      * @param string $bottomButtonText
  391.      */
  392.     public function setBottomButtonText($bottomButtonText): void
  393.     {
  394.         $this->bottomButtonText $bottomButtonText;
  395.     }
  396.     /**
  397.      * @return string
  398.      */
  399.     public function getBottomButtonTextColor()
  400.     {
  401.         return $this->bottomButtonTextColor;
  402.     }
  403.     /**
  404.      * @param $bottomButtonTextColor
  405.      */
  406.     public function setBottomButtonTextColor($bottomButtonTextColor): void
  407.     {
  408.         $this->bottomButtonTextColor $bottomButtonTextColor;
  409.     }
  410.     /**
  411.      * @return string
  412.      */
  413.     public function getBottomButtonColor()
  414.     {
  415.         return $this->bottomButtonColor;
  416.     }
  417.     /**
  418.      * @param $bottomButtonColor
  419.      */
  420.     public function setBottomButtonColor($bottomButtonColor): void
  421.     {
  422.         $this->bottomButtonColor $bottomButtonColor;
  423.     }
  424.     /**
  425.      * @return string
  426.      */
  427.     public function getBottomBackgroundColor()
  428.     {
  429.         return $this->bottomBackgroundColor;
  430.     }
  431.     /**
  432.      * @param $bottomBackgroundColor
  433.      */
  434.     public function setBottomBackgroundColor($bottomBackgroundColor): void
  435.     {
  436.         $this->bottomBackgroundColor $bottomBackgroundColor;
  437.     }
  438.     /**
  439.      * @return string
  440.      */
  441.     public function getBottomTextColor()
  442.     {
  443.         return $this->bottomTextColor;
  444.     }
  445.     /**
  446.      * @param string $bottomTextColor
  447.      */
  448.     public function setBottomTextColor($bottomTextColor): void
  449.     {
  450.         $this->bottomTextColor $bottomTextColor;
  451.     }
  452.     public function getVisibleInPromotions(): ?bool
  453.     {
  454.         return $this->visibleInPromotions;
  455.     }
  456. }