public function addLikedProduct(Product $product) { $product->addLiker($this); $this->likedProducts[] = $product; }
public function loadProduct() { foreach ($this->loadRaw('Product') as $key => $data) { $entity = new Product(); $entity->setName($data['name']); $entity->setUser($this->getReference($data['user'])); foreach ($data['likers'] as $user) { $entity->addLiker($this->getReference($user)); } $this->addReference($key, $entity); $this->manager->persist($entity); } }