/**
  * @param ActionEvent $event
  * @param             $subscribeOptions
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  * @SuppressWarnings(PHPMD.LongVariable)
  */
 protected function handleSubscribeAction(ActionEvent $event, $subscribeOptions)
 {
     global $container, $TL_LANG;
     $environment = $event->getEnvironment();
     $eventDispatcher = $environment->getEventDispatcher();
     $inputProvider = $environment->getInputProvider();
     $recipientRepository = EntityHelper::getRepository('Avisota\\Contao:Recipient');
     $recipientId = $inputProvider->getParameter('recipient');
     $recipient = $recipientRepository->find($recipientId);
     /** @var \Avisota\Contao\Entity\Recipient $recipient */
     $mailingListRepository = EntityHelper::getRepository('Avisota\\Contao:MailingList');
     $mailingListId = $inputProvider->getParameter('mailing-list');
     $mailingList = $mailingListRepository->find($mailingListId);
     /** @var MailingList $mailingList */
     /** @var SubscriptionManager $subscriptionManager */
     $subscriptionManager = $container['avisota.subscription'];
     $subscriptionManager->subscribe($recipient, $mailingList, $subscribeOptions);
     $event = AddMessageEvent::createConfirm(sprintf($TL_LANG['orm_avisota_recipient']['subscribe'], $recipient->getEmail(), $mailingList ? $mailingList->getTitle() : $TL_LANG['orm_avisota_recipient']['subscription_global']));
     $eventDispatcher->dispatch(ContaoEvents::MESSAGE_ADD, $event);
     $event = new RedirectEvent('contao/main.php?do=avisota_recipients#' . md5($recipient->getEmail()));
     $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $event);
 }
 /**
  * Add a message to the contao message array in the session.
  *
  * @param AddMessageEvent $event The event.
  *
  * @return void
  */
 public function addMessage(AddMessageEvent $event)
 {
     Message::add($event->getContent(), 'TL_' . strtoupper($event->getType()));
 }