src/AtechNet/CoreBundle/Entity/Banner.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\AtechNet\CoreBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping\Column;
  6. use Doctrine\ORM\Mapping\Entity;
  7. use Doctrine\ORM\Mapping\JoinColumn;
  8. use Doctrine\ORM\Mapping\ManyToOne;
  9. use Doctrine\ORM\Mapping\OneToMany;
  10. use Doctrine\ORM\Mapping\OrderBy;
  11. use Doctrine\ORM\Mapping\Table as Table;
  12. /**
  13.  * Banner
  14.  *
  15.  * @Table(name="banners")
  16.  * @Entity
  17.  */
  18. class Banner extends AbstractSignedEntity
  19. {
  20.     /**
  21.      * @var Domain
  22.      *
  23.      * @ManyToOne(targetEntity="Domain", inversedBy="banners")
  24.      * @JoinColumn(name="domain_id", referencedColumnName="id")
  25.      */
  26.     private $domain;
  27.     /**
  28.      * @var Collection<int, BannerItem>
  29.      *
  30.      * @OneToMany(targetEntity="BannerItem", mappedBy="banner", orphanRemoval=true)
  31.      * @OrderBy({"created" = "DESC"})
  32.      **/
  33.     private $bannerItems;
  34.     /**
  35.      * @var int
  36.      *
  37.      * @Column(name="count_down", type="integer")
  38.      */
  39.     private $countDown;
  40.     /**
  41.      * @var int
  42.      *
  43.      * @Column(name="type", type="integer")
  44.      */
  45.     private $type;
  46.     /**
  47.      * @var int
  48.      *
  49.      * @Column (name="display_type", type="integer")
  50.      */
  51.     private $displayType;
  52.     // Standard Types
  53.     public const BANNER_MAIN_TYPE = 1;
  54.     public const BANNER_SMALL_UPPER_TYPE = 2;
  55.     public const BANNER_SMALL_LOWER_TYPE = 3;
  56.     // Bazaar Types
  57.     public const BANNER_BAZAAR_MAIN_TYPE = 4;
  58.     public const BANNER_BAZAAR_SMALL_UPPER_TYPE = 5;
  59.     public const BANNER_BAZAAR_SMALL_LOWER_TYPE = 6;
  60.     // Display Types
  61.     public const BANNER_DISPLAY_TYPE_BANNER = 1;
  62.     public const BANNER_DISPLAY_TYPE_PRODUCT = 2;
  63.     public const BANNER_DISPLAY_TYPE_CATEGORY_GROUP = 3;
  64.     /**
  65.      * @return array<int,string>
  66.      */
  67.     public static function getBannerTypes(): array
  68.     {
  69.         return [
  70.             self::BANNER_MAIN_TYPE                  => 'Carousel', 
  71.             self::BANNER_SMALL_UPPER_TYPE           => 'Single upper', 
  72.             self::BANNER_SMALL_LOWER_TYPE           => 'Single lower', 
  73.             self::BANNER_BAZAAR_MAIN_TYPE           => 'Bazaar - Carousel', 
  74.             self::BANNER_BAZAAR_SMALL_UPPER_TYPE    => 'Bazaar - Single upper', 
  75.             self::BANNER_BAZAAR_SMALL_LOWER_TYPE    => 'Bazaar - Single lower'
  76.         ];
  77.     }
  78.     /**
  79.      * @return array<int,string>
  80.      */
  81.     public static function getBannerDisplayTypes(): array
  82.     {
  83.         return [
  84.             self::BANNER_DISPLAY_TYPE_BANNER => 'Banner',
  85.             self::BANNER_DISPLAY_TYPE_PRODUCT => 'Product',
  86.             self::BANNER_DISPLAY_TYPE_CATEGORY_GROUP => 'Category group',
  87.         ];
  88.     }
  89.     public function __construct()
  90.     {
  91.         parent::__construct();
  92.         $this->bannerItems = new ArrayCollection();
  93.     }
  94.     /**
  95.      * @return Domain
  96.      */
  97.     public function getDomain(): Domain
  98.     {
  99.         return $this->domain;
  100.     }
  101.     /**
  102.      * @param Domain $domain
  103.      * 
  104.      * @return void
  105.      */
  106.     public function setDomain($domain): void
  107.     {
  108.         $this->domain = $domain;
  109.     }
  110.     /**
  111.      * @return Collection<int, BannerItem>
  112.      */
  113.     public function getBannerItems(): Collection
  114.     {
  115.         return $this->bannerItems;
  116.     }
  117.     /**
  118.      * @param ArrayCollection<int, BannerItem> $bannerItems
  119.      * 
  120.      * @return void
  121.      */
  122.     public function setBannerItems(ArrayCollection $bannerItems): void
  123.     {
  124.         $this->bannerItems = $bannerItems;
  125.     }
  126.     /**
  127.      * @return int
  128.      */
  129.     public function getCountDown(): int
  130.     {
  131.         return $this->countDown / 1000;
  132.     }
  133.     /**
  134.      * @param int $countDown
  135.      * 
  136.      * @return void
  137.      */
  138.     public function setCountDown(int $countDown): void
  139.     {
  140.         $this->countDown = $countDown * 1000;
  141.     }
  142.     /**
  143.      * @return int
  144.      */
  145.     public function getType(): int
  146.     {
  147.         return $this->type;
  148.     }
  149.     /**
  150.      * @param int $type
  151.      * 
  152.      * @return void
  153.      */
  154.     public function setType(int $type): void
  155.     {
  156.         $this->type = $type;
  157.     }
  158.     /**
  159.      * @return int
  160.      */
  161.     public function getDisplayType(): int
  162.     {
  163.         return $this->displayType;
  164.     }
  165.     /**
  166.      * @param int $displayType
  167.      * 
  168.      * @return void
  169.      */
  170.     public function setDisplayType(int $displayType): void
  171.     {
  172.         $this->displayType = $displayType;
  173.     }
  174. }