コード例 #1
0
 /**
  * Purify objective titles
  * @param OutputInterface $output
  */
 protected function purifyObjectiveTitle(OutputInterface $output)
 {
     $cleanedTitles = 0;
     $offset = 1;
     $limit = self::QUERY_LIMIT;
     $totalObjectives = $this->objectiveManager->getTotalObjectiveCount();
     $progress = new ProgressBar($output, $totalObjectives);
     $progress->setRedrawFrequency(208);
     $output->writeln("<info>Starting cleanup of objective titles...</info>");
     $progress->start();
     do {
         $objectives = $this->objectiveManager->findBy(array(), array('id' => 'ASC'), $limit, $offset);
         foreach ($objectives as $objective) {
             $originalTitle = $objective->getTitle();
             $cleanTitle = $this->purifier->purify($originalTitle);
             if ($originalTitle != $cleanTitle) {
                 $cleanedTitles++;
                 $objective->setTitle($cleanTitle);
                 $this->objectiveManager->update($objective, false);
             }
             $progress->advance();
         }
         $offset += $limit;
         $this->em->flush();
         $this->em->clear();
     } while (count($objectives) == $limit);
     $progress->finish();
     $output->writeln('');
     $output->writeln("<info>{$cleanedTitles} Objective Titles updated.</info>");
 }
コード例 #2
0
ファイル: ObjectiveHandler.php プロジェクト: profcab/ilios
 /**
  * @param Registry $em
  * @param string $class
  * @param FormFactoryInterface $formFactory
  */
 public function __construct(Registry $em, $class, FormFactoryInterface $formFactory)
 {
     $this->formFactory = $formFactory;
     parent::__construct($em, $class);
 }