How can I check that given value exists in Doctrine Collection (ManyToMany relation) field?
For example I try to:
$someClass = $this->
getDoctrine()->
getRepository('MyBundle:MyClass')->
find($id);
if (!$entity->getMyCollectionValues()->get($someClass->getId())) {
$entity->addMyCollectionValue($someClass);
}
But it is of course not correct. So, how to avoid for duplicate keys?