Created
October 12, 2012 13:20
-
-
Save Bendihossan/3879169 to your computer and use it in GitHub Desktop.
related content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param ArrayCollection $related Related item | |
*/ | |
public function setRelated(ArrayCollection $related) | |
{ | |
$this->related = $related; | |
foreach ($related as $relation) { | |
if (! $relation->getRelated()->contains($this)) { | |
$relation->addRelation($this); | |
} | |
} | |
} | |
// The addRelation($relation) method simply adds the relation to the related property: | |
$this->related[] = $relation; | |
//...and checks to see if the inverse relation needs to be added: | |
if (! $relation->getRelated()->contains($this)) { | |
$relation->addRelation($this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment