Beispiel #1
0
 /**
  * @param ImapEmailOrigin $origin
  */
 protected function clearOrigin(ImapEmailOrigin $origin)
 {
     $folders = $origin->getFolders();
     $folderRepository = $this->em->getRepository('OroImapBundle:ImapEmailFolder');
     foreach ($folders as $folder) {
         $imapFolder = $folderRepository->findOneBy(['folder' => $folder]);
         if (!$origin->isActive()) {
             $this->removeFolder($imapFolder);
         } elseif (!$folder->isSyncEnabled()) {
             $this->clearFolder($imapFolder);
             $imapFolder->getFolder()->setSynchronizedAt(null);
         }
     }
     if (!$origin->isActive()) {
         $this->em->remove($origin);
         $this->em->flush();
     }
 }