src/Entity/ProductRecommendation.php line 25

Open in your IDE?
  1. <?php
  2. // src/Acme/UserBundle/Entity/User.php
  3. namespace App\Entity;
  4. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  5. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  6. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  7. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  8. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  9. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. /**
  16.  * @Doctrine\ORM\Mapping\Entity
  17.  * @Doctrine\ORM\Mapping\Table(name="product_recommendation")
  18.  */
  19. class ProductRecommendation implements BlameableInterfaceTimestampableInterface  {
  20.     use BlameableTrait;
  21.     use TimestampableTrait;
  22.     /**
  23.      * @var integer
  24.      *
  25.      * @ORM\Column(name="id", type="integer", nullable=false)
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue(strategy="IDENTITY")
  28.      */
  29.     private $id;
  30.     /**
  31.      * @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\Product", inversedBy="recommendations")
  32.      * @Doctrine\ORM\Mapping\JoinColumn(name="product_id", referencedColumnName="id")
  33.      */
  34.     private $product;
  35.     /**
  36.      * @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\Product")
  37.      * @Doctrine\ORM\Mapping\JoinColumn(name="accessory_id", referencedColumnName="id")
  38.      */
  39.     private $recommendation;
  40.     /**
  41.      * To which locale recommendation is associated to
  42.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\Language", cascade={"persist"})
  43.      */
  44.     protected $languages;
  45.     public function __construct()
  46.     {
  47.         $this->languages = new ArrayCollection();
  48.     }
  49.     /**
  50.      * Get id
  51.      *
  52.      * @return integer
  53.      */
  54.     public function getId()
  55.     {
  56.         return $this->id;
  57.     }
  58.     /**
  59.      * Set product
  60.      *
  61.      * @param \App\Entity\Product $product
  62.      *
  63.      * @return ProductRecommendation
  64.      */
  65.     public function setProduct(\App\Entity\Product $product null)
  66.     {
  67.         $this->product $product;
  68.         return $this;
  69.     }
  70.     /**
  71.      * Get product
  72.      *
  73.      * @return \App\Entity\Product
  74.      */
  75.     public function getProduct()
  76.     {
  77.         return $this->product;
  78.     }
  79.     /**
  80.      * Set recommendation
  81.      *
  82.      * @param \App\Entity\Product $recommendation
  83.      *
  84.      * @return ProductRecommendation
  85.      */
  86.     public function setRecommendation(\App\Entity\Product $recommendation null)
  87.     {
  88.         $this->recommendation $recommendation;
  89.         return $this;
  90.     }
  91.     /**
  92.      * Get recommendation
  93.      *
  94.      * @return \App\Entity\Product
  95.      */
  96.     public function getRecommendation()
  97.     {
  98.         return $this->recommendation;
  99.     }
  100.     /**
  101.      * @return Collection|Language[]
  102.      */
  103.     public function getLanguages(): Collection
  104.     {
  105.         return $this->languages;
  106.     }
  107.     public function addLanguage(Language $language): self
  108.     {
  109.         if (!$this->languages->contains($language)) {
  110.             $this->languages[] = $language;
  111.         }
  112.         return $this;
  113.     }
  114.     public function removeLanguage(Language $language): self
  115.     {
  116.         if ($this->languages->contains($language)) {
  117.             $this->languages->removeElement($language);
  118.         }
  119.         return $this;
  120.     }
  121. }