Example #1
0
 /**
  * @param Configuration $configuration
  * @param ElectionInvitation $electionInvitation
  * @return string
  * @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
  * @throws \TYPO3\CMS\Extbase\Security\Exception\InvalidArgumentForHashGenerationException
  */
 protected function getLink(Configuration $configuration, ElectionInvitation $electionInvitation)
 {
     $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
     $hashService = $objectManager->get(HashService::class);
     if (!isset($GLOBALS['TT'])) {
         $GLOBALS['TT'] = GeneralUtility::makeInstance(TimeTracker::class);
     }
     if (!isset($GLOBALS['TSFE'])) {
         $GLOBALS['TSFE'] = GeneralUtility::makeInstance(TypoScriptFrontendController::class, $GLOBALS['TYPO3_CONF_VARS'], $configuration->getPluginPid(), 0);
         $GLOBALS['TSFE']->config = ['config' => []];
         $GLOBALS['TSFE']->initFEuser();
         $GLOBALS['TSFE']->fetch_the_id();
         $GLOBALS['TSFE']->initTemplate();
     }
     $uriBuilder = $objectManager->get(UriBuilder::class);
     $uriBuilder->setTargetPageUid($configuration->getPluginPid());
     $uriBuilder->setCreateAbsoluteUri(true);
     $uriBuilder->setUseCacheHash(false);
     $uriBuilder->uriFor(FeElectionController::ACTION_VOTE, ['electionInvitation' => $electionInvitation, 'hmac' => $hashService->generateHmac($electionInvitation->getSecret() . $electionInvitation->getElector()->getEmail())], FeElectionController::CONTROLLER_NAME, 'election', 'pi1');
     return $uriBuilder->buildFrontendUri();
 }