/**
  * @param Configuration $configuration
  * @param ElectionCircular $electionCircular
  */
 public function inviteElectors(Configuration $configuration, ElectionCircular $electionCircular)
 {
     $limit = $configuration->getNumberOfMails();
     $receiver = [];
     $possibleReceivers = $electionCircular->getRemainingReceivers();
     while (count($receiver) < $limit && count($possibleReceivers) > 0) {
         /** @var Elector $possibleReceiver */
         $possibleReceiver = array_shift($possibleReceivers);
         $receiver[] = $possibleReceiver;
         $electionInvitation = new ElectionInvitation();
         $electionInvitation->setElector($possibleReceiver);
         $electionInvitation->setElectionCircular($electionCircular);
         $electionInvitation->setSecret(GeneralUtility::getRandomHexString(mt_rand(180, 220)));
         $this->electionInvitationRepository->add($electionInvitation);
         $this->electionInvitationRepository->persistAll();
         $electionInvitation->setSuccess($this->sendElectionInvitation($configuration, $electionInvitation));
         $this->electionInvitationRepository->update($electionInvitation);
         $this->electionInvitationRepository->persistAll();
     }
 }