/**
  * Purify session description
  * @param OutputInterface $output
  */
 protected function purifySessionDescription(OutputInterface $output)
 {
     $cleaned = 0;
     $offset = 1;
     $limit = self::QUERY_LIMIT;
     $total = $this->sessionDescriptionManager->getTotalSessionDescriptionCount();
     $progress = new ProgressBar($output, $total);
     $progress->setRedrawFrequency(208);
     $output->writeln("<info>Starting cleanup of session descriptions...</info>");
     $progress->start();
     do {
         $descriptions = $this->sessionDescriptionManager->findBy(array(), array('id' => 'ASC'), $limit, $offset);
         foreach ($descriptions as $description) {
             $original = $description->getDescription();
             $clean = $this->purifier->purify($original);
             if ($original != $clean) {
                 $cleaned++;
                 $description->setDescription($clean);
                 $this->sessionDescriptionManager->update($description, false);
             }
             $progress->advance();
         }
         $offset += $limit;
         $this->em->flush();
         $this->em->clear();
     } while (count($descriptions) == $limit);
     $progress->finish();
     $output->writeln('');
     $output->writeln("<info>{$cleaned} Session Descriptions updated.</info>");
 }
Example #2
0
 /**
  * @param CourseInterface $newCourse
  * @param CourseInterface $origCourse
  * @param int $daysOffset
  * @param array $options
  * @param array $newCourseObjectives
  */
 protected function rolloverSessions(CourseInterface $newCourse, CourseInterface $origCourse, $daysOffset, $options, array $newCourseObjectives)
 {
     /* @var SessionInterface[] $origCourseSessions */
     $origCourseSessions = $origCourse->getSessions();
     foreach ($origCourseSessions as $origCourseSession) {
         /* @var SessionInterface $newSession */
         $newSession = $this->sessionManager->create();
         $newSession->setCourse($newCourse);
         $newSession->setTitle($origCourseSession->getTitle());
         $newSession->setAttireRequired($origCourseSession->isAttireRequired());
         $newSession->setEquipmentRequired($origCourseSession->isEquipmentRequired());
         $newSession->setSessionType($origCourseSession->getSessionType());
         $newSession->setSupplemental($origCourseSession->isSupplemental());
         $newSession->setPublishedAsTbd(0);
         $newSession->setPublished(0);
         //now check for a session description and, if there is one, set it...
         $origSessionDescription = $origCourseSession->getSessionDescription();
         if (!empty($origSessionDescription)) {
             /* @var SessionDescriptionInterface $newSessionDescription */
             $newSessionDescription = $this->sessionDescriptionManager->create();
             $newSessionDescriptionText = $origSessionDescription->getDescription();
             $newSessionDescription->setDescription($newSessionDescriptionText);
             $newSession->setSessionDescription($newSessionDescription);
             $this->sessionDescriptionManager->update($newSessionDescription, false, false);
         }
         //SESSION LEARNING MATERIALS
         if (empty($options['skip-session-learning-materials'])) {
             $this->rolloverSessionLearningMaterials($newSession, $origCourseSession);
         }
         //SESSION OBJECTIVES
         if (empty($options['skip-session-objectives'])) {
             $this->rolloverSessionObjectives($newSession, $origCourseSession, $newCourseObjectives);
         }
         //SESSION TERMS
         if (empty($options['skip-session-terms'])) {
             $newSession->setTerms($origCourseSession->getTerms());
         }
         //SESSION MESH TERMS
         if (empty($options['skip-session-mesh'])) {
             $newSession->setMeshDescriptors($origCourseSession->getMeshDescriptors());
         }
         //Offerings
         if (empty($options['skip-offerings'])) {
             $this->rolloverOfferings($newSession, $origCourseSession, $daysOffset, $options);
         }
         //ILMSessions
         $this->rolloverIlmSession($newSession, $origCourseSession, $daysOffset);
         $this->sessionManager->update($newSession, false, false);
     }
 }
 /**
  * @param Registry $em
  * @param string $class
  * @param FormFactoryInterface $formFactory
  */
 public function __construct(Registry $em, $class, FormFactoryInterface $formFactory)
 {
     $this->formFactory = $formFactory;
     parent::__construct($em, $class);
 }