public function removeAssociation(Association $association, Entry $entry) { $entryAssociation = $entry->getAssociation($association); if ($entryAssociation) { $inversedAssocation = $this->entityManager->getRepository('Concrete\\Core\\Entity\\Express\\Association')->findOneBy(['target_property_name' => $association->getInversedByPropertyName()]); $associatedEntries = $entryAssociation->getSelectedEntriesCollection(); foreach ($associatedEntries as $associatedEntry) { $associatedEntryAssociation = $associatedEntry->getAssociation($inversedAssocation); if (is_object($associatedEntryAssociation)) { $associatedEntryAssociation->removeSelectedEntry($entry); $this->entityManager->persist($associatedEntryAssociation); } } $this->entityManager->remove($entryAssociation); $this->entityManager->flush(); } }