src/Entity/Product/Product.php line 19

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Product;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Sylius\Component\Core\Model\Product as BaseProduct;
  8. use Sylius\Component\Product\Model\ProductTranslationInterface;
  9. /**
  10.  * @ORM\Entity
  11.  * @ORM\Table(name="sylius_product")
  12.  */
  13. #[ORM\Entity]
  14. #[ORM\Table(name'sylius_product')]
  15. class Product extends BaseProduct
  16. {
  17.     #[ORM\ManyToMany(targetEntityProductSymbol::class)]
  18.     #[ORM\JoinTable(name'app_product_product_symbol')]
  19.     private Collection $symbols;
  20.     public function __construct()
  21.     {
  22.         parent::__construct();
  23.         $this->symbols = new ArrayCollection();
  24.     }
  25.     protected function createTranslation(): ProductTranslationInterface
  26.     {
  27.         return new ProductTranslation();
  28.     }
  29.     /**
  30.      * @return Collection<int, ProductSymbol>
  31.      */
  32.     public function getSymbols(): Collection
  33.     {
  34.         return $this->symbols;
  35.     }
  36.     public function addSymbol(ProductSymbol $symbol): self
  37.     {
  38.         if (!$this->symbols->contains($symbol)) {
  39.             $this->symbols->add($symbol);
  40.         }
  41.         return $this;
  42.     }
  43.     public function removeSymbol(ProductSymbol $symbol): self
  44.     {
  45.         $this->symbols->removeElement($symbol);
  46.         return $this;
  47.     }
  48. }