vendor/bluue/categories-bundle/src/Entity/CategoryProduct.php line 41

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Leo BANNHOLTZER (contact@scaledev.fr)
  4.  * @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
  5.  * @license commercial
  6.  */
  7. declare(strict_types=1);
  8. namespace Bluue\CategoriesBundle\Entity;
  9. use Symfony\Component\Uid\Uuid;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use App\DoctrineExtensions\IsDefaultEntity;
  13. use Bluue\CategoriesBundle\Entity\Category;
  14. use Bluue\ProductsBundle\Entity\ProductContext;
  15. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  16. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  17. use Bluue\CategoriesBundle\Repository\CategoryProductRepository;
  18. use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
  19. use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
  20. /**
  21.  * @ORM\Entity(repositoryClass=CategoryProductRepository::class)
  22.  * @ORM\Table(name="categories_bundle__category_product", indexes={
  23.  *  @ORM\Index(name="is_default", columns={"is_default"}),
  24.  *  @ORM\Index(name="deleted_at", columns={"deleted_at"}),
  25.  *  @ORM\Index(name="created_at", columns={"created_at"}),
  26.  *  @ORM\Index(name="updated_at", columns={"updated_at"})
  27.  * })
  28.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
  29.  * @UniqueEntity(
  30.  *     fields={"category", "productContext"},
  31.  *     errorPath="category",
  32.  *     message="This association between this category and this product context already exists.",
  33.  *     ignoreNull=false
  34.  * )
  35.  */
  36. class CategoryProduct
  37. {
  38.     use UserTimestampableEntity;
  39.     use UserSoftDeleteableEntity;
  40.     use IsDefaultEntity;
  41.     /**
  42.      * @ORM\Id
  43.      * @ORM\Column(type="uuid")
  44.      * @ORM\GeneratedValue(strategy="CUSTOM")
  45.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  46.      */
  47.     private ?Uuid $id null;
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="categoryProducts")
  50.      * @ORM\JoinColumn(nullable=false)
  51.      */
  52.     private Category $category;
  53.     /**
  54.      * @ORM\ManyToOne(targetEntity=ProductContext::class, inversedBy="categoryProducts")
  55.      * @ORM\JoinColumn(nullable=false)
  56.      */
  57.     private ProductContext $productContext;
  58.     /**
  59.      * @return Uuid|null
  60.      */
  61.     public function getId(): ?Uuid
  62.     {
  63.         return $this->id;
  64.     }
  65.     /**
  66.      * @return Category
  67.      */
  68.     public function getCategory(): ?Category
  69.     {
  70.         return $this->category;
  71.     }
  72.     /**
  73.      * @param Category $category
  74.      * @return $this
  75.      */
  76.     public function setCategory(Category $category): self
  77.     {
  78.         $this->category $category;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return ProductContext
  83.      */
  84.     public function getProductContext(): ?ProductContext
  85.     {
  86.         return $this->productContext;
  87.     }
  88.     /**
  89.      * @param ProductContext $productContext
  90.      * @return $this
  91.      */
  92.     public function setProductContext(ProductContext $productContext): self
  93.     {
  94.         $this->productContext $productContext;
  95.         return $this;
  96.     }
  97. }