PHP code example of devskio / ds_notifier
1. Go to this page and download the library: Download devskio/ds_notifier 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/ */
devskio / ds_notifier example snippets
$eventDispatcher = GeneralUtility::makeInstance(EventDispatcher::class);
$eventDispatcher->dispatch(new CacheFlush(new CacheFlushEvent($groups)));
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['templateRootPaths'][700]
= 'EXT:my_site_extension/Resources/Private/Templates/Email';
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['layoutRootPaths'][700]
= 'EXT:my_site_extension/Resources/Private/Layouts';
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['layoutRootPaths'][700]
= 'EXT:my_site_extension/Resources/Private/Layouts';
tx_dsnotifier_domain_model_notification {
layout {
addItems {
TestLayout = Test
AdminLayout = Admin
}
}
}
use Devsk\DsNotifier\Attribute\Event\Email;
use Devsk\DsNotifier\Attribute\Event\Marker;
use Devsk\DsNotifier\Attribute\NotifierEvent;
use Devsk\DsNotifier\Event\AbstractEvent;
#[NotifierEvent(
label: 'Custom event notification',
group: EventGroup::CUSTOMGROUP,
flexibleConfigurationFile: 'FILE:EXT:my_site_extension/Configuration/FlexForms/Notifier/CustomEvent.xml',
)]
class CustomEvent extends AbstractEvent
{
#[Marker('Custom event value')]
protected string $customValue = '';
#[Marker('Custom event other')]
protected string $customOtherValue = '';
#[Email('Custom event email')]
protected $customEmail;
public function __construct(string $customValue,string $customOtherValue, $customEmail)
{
$this->customValue = $customValue;
$this->customOtherValue = $customOtherValue;
$this->customEmail = $customEmail;
}
public function getCustomValue(): string
{
return $this->customValue;
}
public function getCustomOtherValue(): string
{
return $this->customOtherValue;
}
public function getCustomEmail()
{
return $this->customEmail;
}
}
class CustomNotificationChannel extends Notification
{
public function send(EventInterface $event): void
{
// Your custom notification logic here
}
}
Model\Notification::class => [
'subclasses' => [
Model\Notification\CustomNotificationChannel::class => Model\Notification\CustomNotificationChannel::class,
],
],
Model\Notification\CustomNotificationChannel::class => [
'recordType' => Model\Notification\CustomNotificationChannel::class,
'tableName' => Model\Notification\CustomNotificationChannel::tableName(),
],
];
$tca = [
'columns' => [
'channel' => [
'config' => [
'items' => array_merge($GLOBALS['TCA']['tx_dsnotifier_domain_model_notification']['columns']['channel']['config']['items'],[
[
'label' => "{$lll}:tx_dsnotifier_domain_model_notification.channel.customNotificationChannel",
'value' => CustomNotificationChannel::class,
'icon' => 'custom-notification-channel.svg
],
]),
],
],
],
'types' => [
CustomNotificationChannel::class => [
'showitem' => "
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--palette--;;general,
--div--;{$lll}:tx_dsnotifier_domain_model_notification.tab.customNotificationChannel,
--palette--;;customNotificationChannel,
--div--;LLL:EXT:ds_notifier/Resources/Private/Language/locallang_db.xlf:tx_dsnotifier_domain_model_notification.tab.configuration,
--palette--;;configuration,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;access,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
--palette--;;language,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
",
'subtype_value_field' => 'event',
'columnsOverrides' => [
'body' => [
'config' => [
'renderType' => ((new Typo3Version())->getMajorVersion() > 12) ? 'codeEditor' : 't3editor',
'format' => 'html',
],
],
],
],
],
'palettes' => [
'customNotificationChannel' => [
'label' => "{$lll}:tx_dsnotifier_domain_model_notification.palette.customNotificationChannel",
'showitem' => 'body',
],
],
];
$GLOBALS['TCA']['tx_dsnotifier_domain_model_notification'] = array_replace_recursive($GLOBALS['TCA']['tx_dsnotifier_domain_model_notification'], $tca);