コード例 #1
0
 private function removeSystem(System $system)
 {
     $deletedIds = [];
     $em = $this->getDoctrine()->getManager();
     // remove subsystems
     foreach ($system->getSubsystems() as $child) {
         $deletedIds = $this->removeSystem($child);
     }
     // @todo should be done via an event
     // remove integration systems
     $integrationSystems = $this->getDoctrine()->getRepository('KoalamonIntegrationBundle:IntegrationSystem')->findBy(['system' => $system]);
     foreach ($integrationSystems as $integrationSystem) {
         $em->remove($integrationSystem);
     }
     // remove missing request collections
     try {
         $collections = $this->getDoctrine()->getRepository('LeanKoalaIntegrationMissingRequestBundle:Collection')->findBy(['project' => $system->getProject()]);
         foreach ($collections as $collection) {
             $collection->removeSystem($system);
             $em->persist($collection);
         }
     } catch (\Exception $e) {
     }
     // remove eventIdentifiers
     $eventIdentifiers = $this->getDoctrine()->getRepository('KoalamonIncidentDashboardBundle:EventIdentifier')->findBy(['system' => $system]);
     foreach ($eventIdentifiers as $eventIdentifier) {
         $em->remove($eventIdentifier);
     }
     $em->flush();
     $deletedIds[] = $system->getId();
     $em->remove($system);
     $em->flush();
     return $deletedIds;
 }