Skip to content

Instantly share code, notes, and snippets.

@tristanlins
Created July 16, 2014 09:23
Show Gist options
  • Save tristanlins/0eb3a06f4128ac3390ba to your computer and use it in GitHub Desktop.
Save tristanlins/0eb3a06f4128ac3390ba to your computer and use it in GitHub Desktop.
<?php
/**
* Hooks
*/
$GLOBALS['TL_HOOKS']['processFormData'][] = array('Hooks', 'processFormData');
<?php
use NotificationCenter\Model\Notification;
class Hooks
{
public function processFormData($post, $form, $files)
{
$notificationIds = (array) unserialize($form['notifications']);
foreach ($notificationIds as $notificationId) {
if ($notificationId) {
$tokens = [];
foreach ($post as $key => $value) {
$tokens['form_' . $key] = $value;
}
/** @var Notification $notification */
$notification = Notification::findByPk($notificationId);
if (null !== $notification) {
$notification->send($tokens);
}
}
}
}
}
<?php
$GLOBALS['TL_DCA']['tl_form']['fields']['notifications'] = array(
'inputType' => 'checkbox',
'label' => array(
'Benachrichtigungen',
'Wählen Sie hier aus, welche Benachrichtigungen gestartet werden sollen.'
),
'foreignKey' => 'tl_nc_notification.title',
'eval' => array(
'multiple' => true,
'tl_class' => 'clr'
),
'sql' => 'text NULL'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment