modules/QSL/Banner/src/Model/Banner.php line 17

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
  4.  * See https://www.x-cart.com/license-agreement.html for license details.
  5.  */
  6. namespace QSL\Banner\Model;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Banner
  10.  *
  11.  * @ORM\Entity (repositoryClass="\QSL\Banner\Model\Repo\Banner")
  12.  * @ORM\Table (name="banners",
  13.  *    indexes={
  14.  *      @ORM\Index (name="ep", columns={"enabled","position"}),
  15.  *      @ORM\Index (name="effect", columns={"effect"})
  16.  *  }
  17.  * )
  18.  *
  19.  */
  20. class Banner extends \XLite\Model\AEntity
  21. {
  22.     /**
  23.     * banner + category link unique id
  24.     *
  25.     * @var   integer
  26.     *
  27.     * @ORM\Id
  28.     * @ORM\GeneratedValue (strategy="AUTO")
  29.     * @ORM\Column         (type="integer", options={"unsigned": true})
  30.     */
  31.     protected $id;
  32.     /**
  33.     * Title
  34.     *
  35.     * @var   string
  36.     *
  37.     * @ORM\Column (type="string", length=255)
  38.     */
  39.     protected $title;
  40.     /**
  41.     * Title
  42.     *
  43.     * @var   string
  44.     *
  45.     * @ORM\Column (type="string", length=255)
  46.     */
  47.     protected $location;
  48.     /**
  49.     * Categories
  50.     *
  51.     * @var   \Doctrine\Common\Collections\ArrayCollection
  52.     *
  53.     * @ORM\ManyToMany (targetEntity="XLite\Model\Category", inversedBy="banners")
  54.     * @ORM\JoinTable (name="banner_category",
  55.     *      joinColumns={@ORM\JoinColumn(name="banner_id", referencedColumnName="id")},
  56.     *      inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="category_id")}
  57.     * )
  58.     */
  59.     protected $categories;
  60.     /**
  61.     * Banner slides
  62.     *
  63.     * @var   \Doctrine\Common\Collections\Collection
  64.     *
  65.     * @ORM\OneToMany (targetEntity="QSL\Banner\Model\BannerSlide", mappedBy="banner", cascade={"all"})
  66.     * @ORM\OrderBy   ({"position" = "ASC"})
  67.     */
  68.     protected $bannerSlide;
  69.     /**
  70.     * Banner contents
  71.     *
  72.     * @var   \Doctrine\Common\Collections\Collection
  73.     *
  74.     * @ORM\OneToMany (targetEntity="QSL\Banner\Model\Content", mappedBy="banner", cascade={"all"})
  75.     * @ORM\OrderBy   ({"position" = "ASC"})
  76.     */
  77.     protected $contents;
  78.     /**
  79.      * Memberships
  80.      *
  81.      * @var   \Doctrine\Common\Collections\ArrayCollection
  82.      *
  83.      * @ORM\ManyToMany (targetEntity="XLite\Model\Membership", inversedBy="banners")
  84.      * @ORM\JoinTable (name="membership_banner",
  85.      *      joinColumns={@ORM\JoinColumn (name="banner_id", referencedColumnName="id", onDelete="CASCADE")},
  86.      *      inverseJoinColumns={@ORM\JoinColumn (name="membership_id", referencedColumnName="membership_id", onDelete="CASCADE")}
  87.      * )
  88.      */
  89.     protected $memberships;
  90.     /**
  91.     * Banner width
  92.     *
  93.     * @var   integer
  94.     *
  95.     * @ORM\Column (type="integer")
  96.     */
  97.     protected $width 0;
  98.     /**
  99.     * Banner height
  100.     *
  101.     * @var   integer
  102.     *
  103.     * @ORM\Column (type="integer")
  104.     */
  105.     protected $height 0;
  106.     /**
  107.     * Sort position
  108.     *
  109.     * @var   integer
  110.     *
  111.     * @ORM\Column (type="integer")
  112.     */
  113.     protected $position 0;
  114.     /**
  115.     * Enabled
  116.     *
  117.     * @var   boolean
  118.     *
  119.     * @ORM\Column (type="boolean")
  120.     */
  121.     protected $enabled true;
  122.     /**
  123.      * Enabled
  124.      *
  125.      * @var   boolean
  126.      *
  127.      * @ORM\Column (type="boolean")
  128.      */
  129.     protected $parallax false;
  130.     /**
  131.     * Roation effect
  132.     *
  133.     * @var  integer
  134.     *
  135.     * @ORM\Column (type="string", length=255)
  136.     */
  137.     protected $effect;
  138.     /**
  139.     * Banner slide delay
  140.     *
  141.     * @var   integer
  142.     *
  143.     * @ORM\Column (type="integer")
  144.     */
  145.     protected $timeout 4;
  146.     /**
  147.     * Banner animation speed
  148.     *
  149.     * @var   integer
  150.     *
  151.     * @ORM\Column (type="integer")
  152.     */
  153.     protected $delay 3;
  154.     /**
  155.     * Show on home page
  156.     *
  157.     * @var   boolean
  158.     *
  159.     * @ORM\Column (type="boolean")
  160.     */
  161.     protected $home_page true;
  162.     /**
  163.      * Show on product pages
  164.      *
  165.      * @var   boolean
  166.      *
  167.      * @ORM\Column (type="boolean", options={"default":true})
  168.      */
  169.     protected $products_pages true;
  170.     /**
  171.     * Show navigation
  172.     *
  173.     * @var   boolean
  174.     *
  175.     * @ORM\Column (type="boolean")
  176.     */
  177.     protected $navigation false;
  178.     /**
  179.     * Show arrows
  180.     *
  181.     * @var   boolean
  182.     *
  183.     * @ORM\Column (type="boolean")
  184.     */
  185.     protected $arrows false;
  186.     /**
  187.      * Banner constructor.
  188.      * @param array $data
  189.      */
  190.     public function __construct(array $data = [])
  191.     {
  192.         $this->categories  = new \Doctrine\Common\Collections\ArrayCollection();
  193.         $this->memberships = new \Doctrine\Common\Collections\ArrayCollection();
  194.         $this->bannerSlide = new \Doctrine\Common\Collections\ArrayCollection();
  195.         $this->contents    = new \Doctrine\Common\Collections\ArrayCollection();
  196.         parent::__construct($data);
  197.     }
  198.     /**
  199.     * Get escaped title
  200.     *
  201.     * @return string
  202.     */
  203.     public function getTitleEscaped()
  204.     {
  205.         return htmlspecialchars($this->getTitle(), ENT_QUOTES);
  206.     }
  207.     /**
  208.      * @return \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
  209.      */
  210.     public function getBannerSlide()
  211.     {
  212.         return $this->bannerSlide;
  213.     }
  214.     /**
  215.      * @return \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
  216.      */
  217.     public function getContents()
  218.     {
  219.         return $this->contents;
  220.     }
  221.     /**
  222.      * Add categories
  223.      *
  224.      * @param \XLite\Model\Category $categories
  225.      * @return Banner
  226.      */
  227.     public function addCategories(\XLite\Model\Category $categories)
  228.     {
  229.         //$this->categories[] = $categories;
  230.         $this->getCategories()->add($categories);
  231.         return $this;
  232.     }
  233.     /**
  234.      * Get categories
  235.      *
  236.      * @return \Doctrine\Common\Collections\Collection
  237.      */
  238.     public function getCategories()
  239.     {
  240.         return $this->categories;
  241.     }
  242.     /**
  243.      * Clear categories
  244.      */
  245.     public function clearCategories()
  246.     {
  247.         foreach ($this->getCategories()->getKeys() as $key) {
  248.             $this->getCategories()->remove($key);
  249.         }
  250.     }
  251.     /**
  252.      * Add memberships
  253.      *
  254.      * @param \XLite\Model\Membership $memberships
  255.      * @return Banner
  256.      */
  257.     public function addMemberships(\XLite\Model\Membership $memberships)
  258.     {
  259.         $this->memberships[] = $memberships;
  260.         return $this;
  261.     }
  262.     /**
  263.      * Get memberships
  264.      *
  265.      * @return \Doctrine\Common\Collections\Collection
  266.      */
  267.     public function getMemberships()
  268.     {
  269.         return $this->memberships;
  270.     }
  271.     /**
  272.      * Clear memberships
  273.      */
  274.     public function clearMemberships()
  275.     {
  276.         foreach ($this->getMemberships()->getKeys() as $key) {
  277.             $this->getMemberships()->remove($key);
  278.         }
  279.     }
  280.     /**
  281.      * Get id
  282.      *
  283.      * @return integer
  284.      */
  285.     public function getId()
  286.     {
  287.         return $this->id;
  288.     }
  289.     /**
  290.      * Set enabled
  291.      *
  292.      * @param boolean $enabled
  293.      * @return Banner
  294.      */
  295.     public function setEnabled($enabled)
  296.     {
  297.         $this->enabled $enabled;
  298.         return $this;
  299.     }
  300.     /**
  301.      * Get enabled
  302.      *
  303.      * @return boolean
  304.      */
  305.     public function getEnabled()
  306.     {
  307.         return $this->enabled;
  308.     }
  309.     /**
  310.      * Set navigation
  311.      *
  312.      * @param boolean $navigation
  313.      * @return Banner
  314.      */
  315.     public function setNavigation($navigation)
  316.     {
  317.         $this->navigation $navigation;
  318.         return $this;
  319.     }
  320.     /**
  321.      * Get navigation
  322.      *
  323.      * @return boolean
  324.      */
  325.     public function getNavigation()
  326.     {
  327.         return $this->navigation;
  328.     }
  329.     /**
  330.      * Set arrows
  331.      *
  332.      * @param boolean $arrows
  333.      * @return Banner
  334.      */
  335.     public function setArrows($arrows)
  336.     {
  337.         $this->arrows $arrows;
  338.         return $this;
  339.     }
  340.     /**
  341.      * Get navigation
  342.      *
  343.      * @return boolean
  344.      */
  345.     public function getArrows()
  346.     {
  347.         return $this->arrows;
  348.     }
  349.     /**
  350.      * Set enabled
  351.      *
  352.      * @param boolean $parallax
  353.      * @return Banner
  354.      */
  355.     public function setParallax($parallax)
  356.     {
  357.         $this->parallax $parallax;
  358.         return $this;
  359.     }
  360.     /**
  361.      * Get enabled
  362.      *
  363.      * @return boolean
  364.      */
  365.     public function getParallax()
  366.     {
  367.         return $this->parallax;
  368.     }
  369.     /**
  370.      * @param $position
  371.      * @return $this
  372.      */
  373.     public function setPosition($position)
  374.     {
  375.         $this->position $position;
  376.         return $this;
  377.     }
  378.     /**
  379.      * Get position
  380.      *
  381.      * @return boolean
  382.      */
  383.     public function getPosition()
  384.     {
  385.         return $this->position;
  386.     }
  387.     /**
  388.      * @param $timeout
  389.      * @return $this
  390.      */
  391.     public function setTimeout($timeout)
  392.     {
  393.         $this->timeout $timeout;
  394.         return $this;
  395.     }
  396.     /**
  397.      * Get timeout
  398.      *
  399.      * @return boolean
  400.      */
  401.     public function getTimeout()
  402.     {
  403.         return $this->timeout;
  404.     }
  405.     /**
  406.      * @param $delay
  407.      * @return $this
  408.      */
  409.     public function setDelay($delay)
  410.     {
  411.         $this->delay $delay;
  412.         return $this;
  413.     }
  414.     /**
  415.      * Get delay
  416.      *
  417.      * @return boolean
  418.      */
  419.     public function getDelay()
  420.     {
  421.         return $this->delay;
  422.     }
  423.     /**
  424.      * @param $height
  425.      * @return $this
  426.      */
  427.     public function setHeight($height)
  428.     {
  429.         $this->height $height;
  430.         return $this;
  431.     }
  432.     /**
  433.      * Get enabled
  434.      *
  435.      * @return boolean
  436.      */
  437.     public function getHeight()
  438.     {
  439.         return $this->height;
  440.     }
  441.     /**
  442.      * @param $width
  443.      * @return $this
  444.      */
  445.     public function setWidth($width)
  446.     {
  447.         $this->width $width;
  448.         return $this;
  449.     }
  450.     /**
  451.      * Get enabled
  452.      *
  453.      * @return boolean
  454.      */
  455.     public function getWidth()
  456.     {
  457.         return $this->width;
  458.     }
  459.     /**
  460.      * @param $location
  461.      * @return $this
  462.      */
  463.     public function setLocation($location)
  464.     {
  465.         $this->location $location;
  466.         return $this;
  467.     }
  468.     /**
  469.      * Get enabled
  470.      *
  471.      * @return boolean
  472.      */
  473.     public function getLocation()
  474.     {
  475.         return $this->location;
  476.     }
  477.     /**
  478.      * @param $products_pages
  479.      * @return $this
  480.      */
  481.     public function setProductsPages($products_pages)
  482.     {
  483.         $this->products_pages $products_pages;
  484.         return $this;
  485.     }
  486.     /**
  487.      * @return bool
  488.      */
  489.     public function getProductsPages()
  490.     {
  491.         return $this->products_pages;
  492.     }
  493.     /**
  494.      * Set enabled
  495.      *
  496.      * @return integer
  497.      */
  498.     public function setEffect($effect)
  499.     {
  500.         $this->effect $effect;
  501.         return $this;
  502.     }
  503.     /**
  504.      * Get enabled
  505.      *
  506.      * @return boolean
  507.      */
  508.     public function getEffect()
  509.     {
  510.         return $this->effect;
  511.     }
  512.     /**
  513.      * Add images
  514.      *
  515.      * @param \QSL\Banner\Model\BannerSlide $bannerSlide
  516.      * @return BannerSlide
  517.      */
  518.     public function addImages(\QSL\Banner\Model\BannerSlide $bannerSlide)
  519.     {
  520.         $this->bannerSlide[] = $bannerSlide;
  521.         return $this;
  522.     }
  523.     /**
  524.      * Add images
  525.      *
  526.      * @param \QSL\Banner\Model\Content $contents
  527.      * @return Content
  528.      */
  529.     public function addContents(\QSL\Banner\Model\Content $contents)
  530.     {
  531.         $this->contents[] = $contents;
  532.         return $this;
  533.     }
  534. }