/**
  * Purify course learning material note
  * @param OutputInterface $output
  */
 protected function purifyCourseLearningMaterialNote(OutputInterface $output)
 {
     $cleaned = 0;
     $offset = 1;
     $limit = self::QUERY_LIMIT;
     $total = $this->courseLearningMaterialManager->getTotalCourseLearningMaterialCount();
     $progress = new ProgressBar($output, $total);
     $progress->setRedrawFrequency(208);
     $output->writeln("<info>Starting cleanup of course learning material notes...</info>");
     $progress->start();
     do {
         $materials = $this->courseLearningMaterialManager->findBy(array(), array('id' => 'ASC'), $limit, $offset);
         foreach ($materials as $material) {
             $original = $material->getNotes();
             $clean = $this->purifier->purify($original);
             if ($original != $clean) {
                 $cleaned++;
                 $material->setNotes($clean);
                 $this->courseLearningMaterialManager->update($material, false);
             }
             $progress->advance();
         }
         $offset += $limit;
         $this->em->flush();
         $this->em->clear();
     } while (count($materials) == $limit);
     $progress->finish();
     $output->writeln('');
     $output->writeln("<info>{$cleaned} Course Learning Material Notes updated.</info>");
 }
 /**
  * @param Registry $em
  * @param string $class
  * @param FormFactoryInterface $formFactory
  */
 public function __construct(Registry $em, $class, FormFactoryInterface $formFactory)
 {
     $this->formFactory = $formFactory;
     parent::__construct($em, $class);
 }