Пример #1
0
 /**
  * @inheritDoc
  */
 protected function processQuery(JoinWalk $walk)
 {
     $this->logger->notice('Doing hard deletion');
     // Get query
     $this->logger->notice('Getting select query for {target}', ['target' => $walk->getTargetId()]);
     $query = $walk->getQuery();
     $this->debugQuery($query);
     // Output join information
     $this->logger->info((string) $walk);
     // Get iterator
     $iterator = $query->iterate(null);
     // Iterate through results
     $this->logger->notice('Iterating through results...');
     $i = 0;
     $total = 0;
     foreach ($iterator as $result) {
         $entity = $result[0];
         $this->em->remove($entity);
         // Queue delete
         $total++;
         if ($i > $this->chunk->getEstimatedSize()) {
             $this->flush($i);
             // Actually apply changes
             $i = 0;
         }
         $i++;
     }
     if ($i > 0) {
         // Remaining in current chunk
         $this->flush($i);
     } elseif ($i == 0) {
         $this->logger->notice('No results.');
     }
     $this->logger->notice('Done with {target} ({total} deleted)', ['target' => $walk->getTargetId(), 'total' => $total]);
 }
Пример #2
0
 /**
  * @inheritDoc
  */
 protected function processQuery(JoinWalk $walk)
 {
     $this->debugMemory();
     if (!empty($this->clear[$walk->getTargetId()])) {
         $clearFile = $this->getClearFile($walk);
     } else {
         $clearFile = null;
     }
     $class = $this->driver->getEntityMetadata($walk->getTargetId())->getClassMetadata();
     // Get query
     $this->logger->notice('Getting select query for {target}', ['target' => $walk->getTargetId()]);
     $query = $walk->getQuery();
     // Output join information
     $this->logger->info((string) $walk);
     // Output file information
     $file = $this->fileFactory->getFile($this->getClassName($walk->getTargetId()));
     $this->logger->notice('Outputting to {file}', ['file' => (string) $file]);
     // Iterate through results
     $iterator = $query->iterate(null);
     $this->logger->notice('Iterating through results...');
     $i = 0;
     foreach ($iterator as $result) {
         $entity = $result[0];
         $array = $this->entityToArray($entity);
         if ($clearFile) {
             $clear = $this->clear[$walk->getTargetId()];
             $this->writeClearedProperties($clearFile, $class, $entity, $clear['joinFields']);
             $this->clearProperties($class, $array, array_merge($clear['fields'], $clear['joinFields']));
         }
         $file->writeObject($array);
         // Write to file
         $this->em->detach($entity);
         if ($i > $this->chunk->getEstimatedSize()) {
             $this->flush($file, $clearFile, $i);
             $this->em->clear();
         }
         $i++;
     }
     $entity = null;
     $array = null;
     if ($i > 0) {
         // Remaining in current chunk
         $this->flush($file, $clearFile, $i);
     } elseif ($i == 0) {
         $this->logger->notice('No results for export');
     }
     $this->logger->notice('Done with {target}', ['target' => $walk->getTargetId()]);
     $this->close($file, $clearFile);
 }
Пример #3
0
 /**
  * @param JoinWalk $walk
  * @return void
  */
 protected function processQuery(JoinWalk $walk)
 {
     $this->logger->notice('Doing deletion');
     // Get query
     $this->logger->notice('Getting select query for {target}', ['target' => $walk->getTargetId()]);
     $query = $walk->getQuery();
     $this->debugQuery($query);
     // Output join information
     $this->logger->info((string) $walk);
     // Get iterator
     $iterator = $query->iterate(null);
     // Output file information
     $file = $this->fileFactory->getFile($this->getClassName($walk->getTargetId()));
     $this->logger->notice('Outputting to {file}', ['file' => (string) $file]);
     // Iterate through results
     $this->logger->notice('Iterating through results...');
     $i = 0;
     foreach ($iterator as $result) {
         $entity = $result[0];
         $array = $this->entityToArray($entity);
         $file->writeObject($array);
         // Write to file
         $this->em->remove($entity);
         // Queue delete
         $i++;
         if ($i > $this->chunk->getEstimatedSize()) {
             $this->flush($file, $i);
             // Actually apply changes
             $i = 0;
         }
     }
     if ($i > 0) {
         // Remaining in current chunk
         $this->flush($file, $i);
     } elseif ($i == 0) {
         $this->logger->notice('No results.');
     }
     $this->logger->notice('Done with {target}', ['target' => $walk->getTargetId()]);
     $file->close();
 }
Пример #4
0
 /**
  * @param JoinWalk $walk
  * @return AbstractFile
  */
 protected function getClearFile(JoinWalk $walk)
 {
     return $this->fileFactory->getFile($this->getClassName($walk->getTargetId()) . ClearPass::FILE_SUFFIX);
 }