<?php
namespace App\AtechNet\CoreBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\Table;
/**
* CategoryGroup
*
* @Table(name="category_group")
* @Entity
* @HasLifecycleCallbacks
*/
class CategoryGroup extends AbstractSignedEntity
{
public const int CG_TYPE_FEATURED_CATEGORIES_UPPER = 1;
public const int CG_TYPE_FEATURED_CATEGORIES_LOWER = 2;
public const int CG_TYPE_BAZAAR_FEATURED_CATEGORIES_UPPER = 3;
public const int CG_TYPE_BAZAAR_FEATURED_CATEGORIES_LOWER = 4;
/**
* @return array<int,string>
*/
public static function getPositionList(): array
{
return [
self::CG_TYPE_FEATURED_CATEGORIES_UPPER => 'Header featured categories upper',
self::CG_TYPE_FEATURED_CATEGORIES_LOWER => 'Header featured categories lower',
self::CG_TYPE_BAZAAR_FEATURED_CATEGORIES_UPPER => 'Bazaar - Header featured categories upper',
self::CG_TYPE_BAZAAR_FEATURED_CATEGORIES_LOWER => 'Bazaar - Header featured categories lower'
];
}
/**
* @return array<int,string>
*/
public static function getImageSizeForType(): array
{
return [
self::CG_TYPE_FEATURED_CATEGORIES_UPPER => '360x160px',
self::CG_TYPE_FEATURED_CATEGORIES_LOWER => '360x160px',
self::CG_TYPE_BAZAAR_FEATURED_CATEGORIES_UPPER => '360x160px',
self::CG_TYPE_BAZAAR_FEATURED_CATEGORIES_LOWER => '360x160px'
];
}
/**
* @var Domain
*
* @ManyToOne(targetEntity="Domain")
* @JoinColumn(name="domain_id", referencedColumnName="id")
*/
private $domain;
/**
* @var bool
*
* @Column(name="active", type="boolean", nullable=false)
*/
private $active = false;
/**
* @var int
*
* @Column(name="type_id", type="integer")
*/
private $type;
/**
* @var Collection<int,CategoryGroupMember>
*
* @OneToMany(targetEntity="CategoryGroupMember", mappedBy="group", orphanRemoval=true)
**/
private $categories;
/**
* @return Domain
*/
public function getDomain(): Domain
{
return $this->domain;
}
/**
* @param Domain $domain
* @return self
*/
public function setDomain(Domain $domain): self
{
$this->domain = $domain;
return $this;
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param bool $active
* @return self
*/
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
/**
* @return int
*/
public function getType(): ?int
{
return $this->type;
}
/**
* @param int $type
* @return self
*/
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int,CategoryGroupMember>
*/
public function getCategories(): Collection
{
return $this->categories;
}
/**
* @param Collection<int,CategoryGroupMember> $categories
* @return self
*/
public function setCategories(Collection $categories): self
{
$this->categories = $categories;
return $this;
}
/**
* @return void
*/
public function removeAllMember(): void
{
$this->categories->clear();
}
public function addCategory(CategoryGroupMember $member): self
{
if (!$this->categories->contains($member)) {
$this->categories->add($member);
$member->setGroup($this);
}
return $this;
}
public function removeCategory(CategoryGroupMember $member): self
{
$this->categories->removeElement($member);
return $this;
}
}