private function addToLocalSecret($eguide, $spotDetail)
 {
     // add to EGuideToSpotDetail
     $obj = $this->_em->getRepository('BugglMainBundle:EGuideToSpotDetail')->findOneBy(array('eGuide' => $eguide, 'spotDetail' => $spotDetail));
     if (!$obj) {
         $lastOrder = $this->_em->getRepository('BugglMainBundle:EGuideToSpotDetail')->getLastOrderByGuide($eguide);
         $order = $lastOrder ? (int) $lastOrder[0]->getOrder() + 1 : 1;
         $obj = new EGuideToSpotDetail();
         $obj->setEGuide($eguide);
         $obj->setSpotDetail($spotDetail);
         $obj->setOrder($order);
         $obj->setDateAdded($spotDetail->getDateAdded());
         $this->_em->persist($obj);
         $this->_em->flush();
     }
 }
 private function saveAsLocalSecret(\Buggl\MainBundle\Entity\EGuide $eguide, \Buggl\MainBundle\Entity\SpotDetail $detail)
 {
     $obj = $this->getDoctrine()->getRepository('BugglMainBundle:EGuideToSpotDetail')->findOneBy(array('eGuide' => $eguide, 'spotDetail' => $detail));
     if (!$obj) {
         $em = $this->getDoctrine()->getEntityManager();
         $lastOrder = $em->getRepository('BugglMainBundle:EGuideToSpotDetail')->getLastOrderByGuide($eguide);
         $order = $lastOrder ? (int) $lastOrder[0]->getOrder() + 1 : 1;
         $obj = new EGuideToSpotDetail();
         $obj->setEGuide($eguide);
         $obj->setSpotDetail($detail);
         $obj->setOrder($order);
         $obj->setIsFeatured(0);
         $dateAdded = new \DateTime(date('Y-m-d H:i:s'));
         $obj->setDateAdded($dateAdded);
         $em->persist($obj);
         $em->flush();
     }
 }