/** * Deletes a Ofac entity. * * @Route("/{id}/delete", name="ofac_delete", requirements={"id"="\d+"}) * @Method("DELETE") */ public function deleteAction(Ofac $ofac, Request $request) { $form = $this->createDeleteForm($ofac->getId(), 'ofac_delete'); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->remove($ofac); $em->flush(); } return $this->redirect($this->generateUrl('ofac')); }
/** * Update the current Ofac List with the most up to date version * */ public function updateOfac() { $xml = $this->retrieveMostUpToDateOfacList(); if ($xml !== FALSE) { $connection = $this->em->getConnection(); $platform = $connection->getDatabasePlatform(); $connection->executeUpdate($platform->getTruncateTableSQL('forexOfac', true)); $this->em->getConfiguration()->getResultCacheImpl()->delete('AllOfac'); foreach ($xml->sdnEntry as $sdnEntry) { $ofac = new Ofac(); $ofac->setFirstname($sdnEntry->firstName); $ofac->setLastname($sdnEntry->lastName); $ofac->setType($sdnEntry->sdnType); $ofac->setDetails(json_encode($sdnEntry)); $this->em->persist($ofac); } $this->em->flush(); // Save Ofac List into database and use Cache Strategy (memcached) $this->em->getRepository('ForexApplicationBundle:Ofac')->createQueryBuilder('p')->getQuery()->useResultCache(true)->setResultCacheId('AllOfac'); } }