PHP code example of rkw / rkw-registration
1. Go to this page and download the library: Download rkw/rkw-registration library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rkw / rkw-registration example snippets
/**
* Handles opt-in event
*
* @param \RKW\RkwRegistration\Domain\Model\FrontendUser $frontendUser
* @param \RKW\RkwRegistration\Domain\Model\OptIn $optIn
* @return void
* @throws \RKW\RkwMailer\Exception
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException
* @throws \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException
*/
public function optIn (
\RKW\RkwRegistration\Domain\Model\FrontendUser $frontendUser,
\RKW\RkwRegistration\Domain\Model\OptIn $optIn
): void {
// get settings
$settings = $this->getSettings(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$settingsDefault = $this->getSettings();
if ($settings['view']['templateRootPaths']) {
/** @var \RKW\RkwMailer\Service\MailService $mailService */
$mailService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(MailService::class);
// send new user an email with token
$mailService->setTo($frontendUser, array(
'marker' => array(
'frontendUser' => $frontendUser,
'optIn' => $optIn,
'pageUid' => intval($GLOBALS['TSFE']->id),
'loginPid' => intval($settingsDefault['loginPid']),
),
));
$mailService->getQueueMail()->setSubject(
FrontendLocalizationUtility::translate(
'rkwMailService.optInAlertUser.subject',
'rkw_alerts',
null,
$frontendUser->getTxRkwregistrationLanguageKey()
)
);
$mailService->getQueueMail()->addTemplatePaths($settings['view']['templateRootPaths']);
$mailService->getQueueMail()->addPartialPaths($settings['view']['partialRootPaths']);
$mailService->getQueueMail()->setPlaintextTemplate('Email/OptInAlertUser');
$mailService->getQueueMail()->setHtmlTemplate('Email/OptInAlertUser');
$mailService->send();
}
}
/**
* @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher
*/
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
$signalSlotDispatcher->connect(
RKW\RkwRegistration\Registration\AbstractRegistration::class,
RKW\RkwRegistration\Registration\AbstractRegistration::SIGNAL_AFTER_CREATING_OPTIN . 'RkwAlerts',
RKW\RkwAlerts\Service\RkwMailService::class,
'optInAlertUser'
);
public function optInAction(string $tokenUser, string $token): void
{
/** @var \RKW\RkwRegistration\Registration\FrontendUserRegistration $registration */
$registration = $this->objectManager->get(FrontendUserRegistration::class);
$result = $registration->setFrontendUserToken($tokenUser)
->setCategory('rkwAlerts')
->setRequest($this->request)
->validateOptIn($token);
if ($result >= 200 && $result < 300) {
// sucessfull
} elseif ($result >= 300 && $result < 400) {
// canceled
} else {
// error / not found
}
}
$signalSlotDispatcher->connect(
RKW\RkwRegistration\Registration\AbstractRegistration::class,
\RKW\RkwRegistration\Registration\AbstractRegistration::SIGNAL_AFTER_REGISTRATION_COMPLETED . 'RkwAlerts',
'RKW\\RkwAlerts\\Alerts\\AlertManager',
'saveAlertByRegistration'
);