/**
  * One week, two weeks and one month before a panel, the teacher organizing the panel
  * is reminded of the upcoming panel.
  *
  * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
  */
 public function sendReminderForPanelsCommand()
 {
     $reminders = array('oneweek', 'twoweeks', 'onemonth');
     foreach ($reminders as $reminder) {
         $affectedPanels = $this->panelRepository->findPanelsWithinDateConstraintWithoutReminderEmailSent($reminder);
         $this->outputLine('Panels due in ' . $reminder . ': ' . count($affectedPanels));
         foreach ($affectedPanels as $panel) {
             /** @var $panel \Visol\EasyvoteEducation\Domain\Model\Panel */
             if (is_null($panel->getDate())) {
                 // If panel has not date, we don't send a reminder (obviously)
                 return TRUE;
             }
             $this->outputLine($panel->getDate()->format('Y-m-d') . ' | ' . $panel->getTitle() . ' | Sending reminder to ' . $panel->getCommunityUser()->getEmail());
             // Send reminder e-mail to teacher
             /** @var \Visol\Easyvote\Service\TemplateEmailService $templateEmail */
             $templateEmail = $this->objectManager->get('Visol\\Easyvote\\Service\\TemplateEmailService');
             $templateEmail->addRecipient($panel->getCommunityUser());
             $templateEmail->setTemplateName('panelReminder' . ucfirst($reminder) . 'Teacher');
             $templateEmail->setExtensionName('easyvote_education');
             $templateEmail->assign('panel', $panel);
             $templateEmail->enqueue();
             $setter = 'setReminder' . ucfirst($reminder) . 'Sent';
             $panel->{$setter}(TRUE);
             $this->panelRepository->update($panel);
             $this->persistenceManager->persistAll();
         }
     }
 }