/** * @param AgencyAccount $agency_account * @param bool $flush * @return AgencyAccount */ public function remove(AgencyAccount $agency_account, $flush = true) { foreach ($this->accountOwnerManager->getByAccountAndAgency($agency_account->getAccount(), $agency_account->getAgency()) as $account_owner) { $this->accountOwnerManager->end($account_owner, false); } $this->em->remove($agency_account); if ($flush) { $this->em->flush(); } return $agency_account; }