Skip to content

Instantly share code, notes, and snippets.

@khepin
Created August 19, 2011 04:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khepin/1156036 to your computer and use it in GitHub Desktop.
Save khepin/1156036 to your computer and use it in GitHub Desktop.
<?php
//... Product class code ...
public function addTags(\Khepin\ProductBundle\Entity\Tag $tags)
{
$this->tags[] = $tags;
$tags->setProduct($this);
}
public function setTags(array $tags){
$this->tags = new \Doctrine\Common\Collections\ArrayCollection($tags);
foreach ($tags as $tag){
$tag->setProduct($this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment