/** * @param int $optInId * @param bool $enable * @param Contact $contact */ public function updateOptInForContact($optInId, $enable, Contact $contact) { $optIn = $this->findEntityById('optIn', $optInId); $collection = new ArrayCollection(); $collection->add($optIn); if ($enable) { $contact->addOptIn($collection); } else { $contact->removeOptIn($collection); } $this->updateEntity($contact); }