Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Entities;
- use \Doctrine\Common\Collections\ArrayCollection, Entities\Feature;
- /**
- * @Entity
- * @Table(name="products")
- */
- class Product {
- /**
- * @Id @Column(type="integer")
- * @GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ManyToMany(targetEntity="Feature", cascade={"persist"})
- * @JoinTable(
- * name="product_features",
- * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
- * inverseJoinColumns={@JoinColumn(name="feature_id", referencedColumnName="id")}
- * )
- */
- private $features;
- public function __construct()
- {
- $this->features = new ArrayCollection;
- }
- public function getId()
- {
- return $this->id;
- }
- public function addFeature(Feature $feature)
- {
- if (!$this->features->contains($feature))
- {
- $this->features->add($feature);
- $feature->addProduct($this);
- }
- }
- public function getFeatures()
- {
- return $this->features;
- }
- }
Add Comment
Please, Sign In to add comment