Created
          July 16, 2014 09:23 
        
      - 
      
- 
        Save tristanlins/0eb3a06f4128ac3390ba to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| /** | |
| * Hooks | |
| */ | |
| $GLOBALS['TL_HOOKS']['processFormData'][] = array('Hooks', 'processFormData'); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?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); | |
| } | |
| } | |
| } | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?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