src/Entity/ProductFamily.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\BaseLocalizedWebspaceInterface;
  4. use App\Entity\Trait\BaseLocalizedWebspaceTrait;
  5. use App\Entity\Trait\RoutableTrait;
  6. use App\Entity\Trait\SeoTrait;
  7. use App\Entity\Trait\SocialTrait;
  8. use App\Repository\ProductFamilyRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Sulu\Bundle\MediaBundle\Entity\Media;
  13. #[ORM\Entity(repositoryClassProductFamilyRepository::class)]
  14. #[ORM\Table('app_product_families')]
  15. class ProductFamily implements BaseLocalizedWebspaceInterface
  16. {
  17.     use BaseLocalizedWebspaceTrait;
  18.     use RoutableTrait;
  19.     use SeoTrait;
  20.     use SocialTrait;
  21.     public const RESOURCE_KEY 'product_families';
  22.     public const SOCIAL_OG_IMAGES_TABLE 'app_product_family_social_og_images';
  23.     public const SOCIAL_TWITTER_IMAGES_TABLE 'app_product_family_social_twitter_images';
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column]
  27.     private ?int $id null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $title null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $importId null;
  32.     #[ORM\Column(length50uniquetruenullabletrue)]
  33.     private ?string $slug null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $category null;
  36.     #[ORM\ManyToOne(fetch'EXTRA_LAZY')]
  37.     #[ORM\JoinColumn(referencedColumnName'id'nullabletrueonDelete'SET NULL')]
  38.     private ?Media $image null;
  39.     #[ORM\ManyToMany(targetEntityProduct::class, fetch'EXTRA_LAZY')]
  40.     private Collection $referenceList;
  41.     #[ORM\ManyToOne(fetch'EXTRA_LAZY')]
  42.     #[ORM\JoinColumn(referencedColumnName'id'onDelete'SET NULL')]
  43.     private ?ProductCategory $productCategory null;
  44.     public function __construct()
  45.     {
  46.         $this->socialInit();
  47.         $this->referenceList = new ArrayCollection();
  48.     }
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getCategory(): ?string
  54.     {
  55.         return $this->category;
  56.     }
  57.     public function setCategory(?string $category): static
  58.     {
  59.         $this->category $category;
  60.         return $this;
  61.     }
  62.     public function getProductCategory(): ?ProductCategory
  63.     {
  64.         return $this->productCategory;
  65.     }
  66.     public function setProductCategory(?ProductCategory $productCategory): static
  67.     {
  68.         $this->productCategory $productCategory;
  69.         return $this;
  70.     }
  71.     public function isProductCategory(): bool
  72.     {
  73.         return isset($this->productCategory);
  74.     }
  75.     public function getTitle(): ?string
  76.     {
  77.         return $this->title;
  78.     }
  79.     public function setTitle(string $title): static
  80.     {
  81.         $this->title $title;
  82.         return $this;
  83.     }
  84.     public function getImportId(): ?string
  85.     {
  86.         return $this->importId;
  87.     }
  88.     public function setImportId(string $importId): static
  89.     {
  90.         $this->importId $importId;
  91.         return $this;
  92.     }
  93.     public function hasSlug(): bool
  94.     {
  95.         return $this->slug !== null;
  96.     }
  97.     public function getSlug(): ?string
  98.     {
  99.         return $this->slug;
  100.     }
  101.     public function setSlug(?string $slug): static
  102.     {
  103.         $this->slug $slug;
  104.         return $this;
  105.     }
  106.     public function getImage(): ?Media
  107.     {
  108.         return $this->image;
  109.     }
  110.     public function setImage(?Media $image): static
  111.     {
  112.         $this->image $image;
  113.         return $this;
  114.     }
  115.     public function isImage(): bool
  116.     {
  117.         return isset($this->image);
  118.     }
  119.     /**
  120.      * @return Collection<int, Product>
  121.      */
  122.     public function getReferenceList(): Collection
  123.     {
  124.         return $this->referenceList;
  125.     }
  126.     public function addReferenceList(Product $referenceList): static
  127.     {
  128.         if (!$this->referenceList->contains($referenceList)) {
  129.             $this->referenceList->add($referenceList);
  130.             $referenceList->addCategory($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeReferenceList(Product $referenceList): static
  135.     {
  136.         if ($this->referenceList->removeElement($referenceList)) {
  137.             $referenceList->removeCategory($this);
  138.         }
  139.         return $this;
  140.     }
  141. }