src/AtechNet/CoreBundle/Entity/CategoryGroup.php line 22

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\HasLifecycleCallbacks;
  8. use Doctrine\ORM\Mapping\JoinColumn;
  9. use Doctrine\ORM\Mapping\ManyToOne;
  10. use Doctrine\ORM\Mapping\OneToMany;
  11. use Doctrine\ORM\Mapping\Table;
  12. /**
  13.  * CategoryGroup
  14.  *
  15.  * @Table(name="category_group")
  16.  * @Entity
  17.  * @HasLifecycleCallbacks
  18.  */
  19. class CategoryGroup extends AbstractSignedEntity
  20. {
  21.     public const int CG_TYPE_FEATURED_CATEGORIES_UPPER = 1;
  22.     public const int CG_TYPE_FEATURED_CATEGORIES_LOWER = 2;
  23.     public const int CG_TYPE_BAZAAR_FEATURED_CATEGORIES_UPPER = 3;
  24.     public const int CG_TYPE_BAZAAR_FEATURED_CATEGORIES_LOWER = 4;
  25.     /**
  26.      * @return array<int,string>
  27.      */
  28.     public static function getPositionList(): array
  29.     {
  30.         return [
  31.             self::CG_TYPE_FEATURED_CATEGORIES_UPPER         => 'Header featured categories upper', 
  32.             self::CG_TYPE_FEATURED_CATEGORIES_LOWER         => 'Header featured categories lower', 
  33.             self::CG_TYPE_BAZAAR_FEATURED_CATEGORIES_UPPER  => 'Bazaar - Header featured categories upper', 
  34.             self::CG_TYPE_BAZAAR_FEATURED_CATEGORIES_LOWER  => 'Bazaar - Header featured categories lower'
  35.         ];
  36.     }
  37.     /**
  38.      * @return array<int,string>
  39.      */
  40.     public static function getImageSizeForType(): array
  41.     {
  42.         return [
  43.             self::CG_TYPE_FEATURED_CATEGORIES_UPPER         => '360x160px', 
  44.             self::CG_TYPE_FEATURED_CATEGORIES_LOWER         => '360x160px', 
  45.             self::CG_TYPE_BAZAAR_FEATURED_CATEGORIES_UPPER  => '360x160px', 
  46.             self::CG_TYPE_BAZAAR_FEATURED_CATEGORIES_LOWER  => '360x160px'
  47.         ];
  48.     }
  49.     /**
  50.      * @var Domain
  51.      *
  52.      * @ManyToOne(targetEntity="Domain")
  53.      * @JoinColumn(name="domain_id", referencedColumnName="id")
  54.      */
  55.     private $domain;
  56.     /**
  57.      * @var bool
  58.      *
  59.      * @Column(name="active", type="boolean", nullable=false)
  60.      */
  61.     private $active = false;
  62.     /**
  63.      * @var int
  64.      *
  65.      * @Column(name="type_id", type="integer")
  66.      */
  67.     private $type;
  68.     /**
  69.      * @var Collection<int,CategoryGroupMember>
  70.      *
  71.      * @OneToMany(targetEntity="CategoryGroupMember", mappedBy="group", orphanRemoval=true)
  72.      **/
  73.     private $categories;
  74.     /**
  75.      * @return Domain
  76.      */
  77.     public function getDomain(): Domain
  78.     {
  79.         return $this->domain;
  80.     }
  81.     /**
  82.      * @param Domain $domain
  83.      * @return self
  84.      */
  85.     public function setDomain(Domain $domain): self
  86.     {
  87.         $this->domain = $domain;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return bool
  92.      */
  93.     public function isActive(): bool
  94.     {
  95.         return $this->active;
  96.     }
  97.     /**
  98.      * @param bool $active
  99.      * @return self
  100.      */
  101.     public function setActive(bool $active): self
  102.     {
  103.         $this->active = $active;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return int
  108.      */
  109.     public function getType(): ?int
  110.     {
  111.         return $this->type;
  112.     }
  113.     /**
  114.      * @param int $type
  115.      * @return self
  116.      */
  117.     public function setType(int $type): self
  118.     {
  119.         $this->type = $type;
  120.         return $this;
  121.     }
  122.     /**
  123.      * @return Collection<int,CategoryGroupMember>
  124.      */
  125.     public function getCategories(): Collection
  126.     {
  127.         return $this->categories;
  128.     }
  129.     /**
  130.      * @param Collection<int,CategoryGroupMember> $categories
  131.      * @return self
  132.      */
  133.     public function setCategories(Collection $categories): self
  134.     {
  135.         $this->categories = $categories;
  136.         return $this;
  137.     }
  138.     /**
  139.      * @return void
  140.      */
  141.     public function removeAllMember(): void
  142.     {
  143.         $this->categories->clear();
  144.     }
  145.     public function addCategory(CategoryGroupMember $member): self
  146.     {
  147.         if (!$this->categories->contains($member)) {
  148.             $this->categories->add($member);
  149.             $member->setGroup($this);
  150.         }
  151.         return $this;
  152.     }
  153.     public function removeCategory(CategoryGroupMember $member): self
  154.     {
  155.         $this->categories->removeElement($member);
  156.         return $this;
  157.     }
  158. }