/**
  * Retourne les nouveaux enregistrements pour une base
  * @param string $db
  * @return array
  */
 public function getLonesomeRecordsByBase($db)
 {
     $keyRef = AbstractDiff::getKeysRef();
     $db = $keyRef[$db];
     $lonesomeRecords = $this->getData();
     foreach ($lonesomeRecords as $catalogNumber => $classesWithItems) {
         $filteredLonesomeRecords = array_filter($classesWithItems, function ($items) use($db) {
             $itemsFiltered = array_filter($items, function ($item) use($db) {
                 return $item['db'] == $db;
             });
             return count($itemsFiltered) > 0;
         });
         if (count($filteredLonesomeRecords)) {
             $lonesomeRecords[$catalogNumber] = $filteredLonesomeRecords;
         } else {
             unset($lonesomeRecords[$catalogNumber]);
         }
     }
     return $lonesomeRecords;
 }
 /**
  * @Route("{institutionCode}/{collectionCode}/export/setPrefs/{type}", name="setPrefsForExport",
  *     requirements={"type"="dwc|csv"})
  * @param UserInterface|User $user
  * @param Request $request
  * @param string $institutionCode
  * @param string $collectionCode
  * @param string $type
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  */
 public function setPrefsForExportAction(UserInterface $user, Request $request, $institutionCode, $collectionCode, $type)
 {
     $collection = $this->get('utility')->getCollection($institutionCode, $collectionCode, $user);
     $statsManager = $this->get('statsmanager')->init($user, $collection);
     $exportPrefs = new ExportPrefs();
     $form = $this->createForm(ExportPrefsType::class, $exportPrefs, ['action' => $this->generateUrl('setPrefsForExport', ['institutionCode' => $institutionCode, 'collectionCode' => $collectionCode, 'type' => $type])]);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         set_time_limit(0);
         $paramsExport = ['collectionCode' => $collectionCode, 'institutionCode' => $institutionCode, 'exportPrefs' => serialize($exportPrefs)];
         switch ($type) {
             case 'dwc':
                 return $this->redirectToRoute('export', array_merge($paramsExport, ['type' => 'dwc']));
             case 'csv':
                 return $this->redirectToRoute('export', array_merge($paramsExport, ['type' => 'csv']));
         }
     }
     $sumStats = $statsManager->getSumStats();
     $statsChoices = $statsManager->getStatsChoices();
     $sumLonesomeRecords = $statsManager->getSumLonesomeRecords();
     return $this->render('@App/Front/setPrefsForExport.html.twig', array('collection' => $collection, 'sumStats' => $sumStats, 'statsChoices' => $statsChoices, 'sumLonesomeRecords' => $sumLonesomeRecords, 'form' => $form->createView(), 'keysRef' => AbstractDiff::getKeysRef()));
 }