dmk / mkoptin
MK Optin Extension
Installs: 57
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 13
Forks: 0
Open Issues: 0
Type:typo3-cms-extension
Requires
- php: ^7.4
- typo3/cms-backend: ^10.4
- typo3/cms-core: ^10.4
- typo3/cms-extbase: ^10.4
- typo3/cms-fluid: ^10.4
Requires (Dev)
- captainhook/captainhook: ^5.10
- friendsofphp/php-cs-fixer: ^3.3
- helmich/typo3-typoscript-lint: ^2.5
- nimut/testing-framework: ^5.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpcompatibility/php-compatibility: ^9.3.5
- phpmd/phpmd: ^2.11
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.2
- saschaegerer/phpstan-typo3: ^1.0
- sebastian/phpcpd: ^5.0
This package is auto-updated.
Last update: 2024-12-08 14:29:21 UTC
README
This TYPO3 extension provides an opt-in process via fluid mails.
What it does in short:
- Can be triggered to send an Opt-In-E-Mail
- Processes the verification via activation link in email.
- triggers a opt-in validation success event.
- Adds opt-in information to tca.
Installation
Install TYPO3 via composer.
From project root you need to run
composer require dmk/mkoptin
Start a new opt-in process
class MyAwesomeManager { private OptinManager $optinManager; public function __construct( OptinManager $optinManager ) { $this->optinManager = $optinManager; } protected function handleOptIn(string $email): void { $optin = $this->optinManager->createOptinForEmail($email); // opt in already done :) if ($optin->isValidated()) { // opt-in already performed, do your finalize stuff here return; } // opt-in outstanding, send opt-in mail // finalize stuff has to be performed by event listener after opt-in validation $this->optinManager->sendValidationMailForOptin($optin); } }
register opt-in validation success event listeners
Why we need this?
To do things after the email has been verified, such as activate the record or
send confirmation emails.
services: DMK\MyAwesomeExtension\Event\EventListener\OptinValidationSuccessEventListener: tags: - name: 'event.listener' identifier: 'MyAwesomeOptinValidationSuccessEventListener' event: DMK\Optin\Event\OptinValidationSuccessEvent
class OptinValidationSuccessEventListener { private MyAwesomeManager $manager; public function __construct( MyAwesomeManager $manager ) { $this->manager = $manager; } public function __invoke(OptinValidationSuccessEvent $event): void { $this->manager->handleOptinValidation($event->getOptin()); } } class MyAwesomeManager { public function handleOptinValidation(Optin $optin): void { // opt-in performed, do your finalize stuff here } }
Add opt-in information to TCA
In order to output the opt-in information for a data record, the following TCA column must be added:
return [ 'columns' => [ 'optin' => [ 'label' => 'LLL:EXT:mkoptin/Resources/Private/Language/locallang_db.xlf:tx_mkoptin_domain_model_optin', 'config' => [ 'type' => 'user', 'renderType' => 'optInStateElement', ], ], ] ];
WARNING: Currently the field in the data record must always be email
!
Templates
plugin {
tx_mkoptin {
view {
templateRootPath = EXT:myawesomeextension/Resources/Private/Templates/Optin
partialRootPath = EXT:myawesomeextension/Resources/Private/Partials/Optin
layoutRootPath = EXT:myawesomeextension/Resources/Private/Layouts/Optin
}
}
}
@TODOs
- Implement table email field configuration