PHP code example of heimrichhannot / contao-alert-reminder-bundle

1. Go to this page and download the library: Download heimrichhannot/contao-alert-reminder-bundle 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/ */

    

heimrichhannot / contao-alert-reminder-bundle example snippets


   // config.php (or use yaml tags in contao 4.9+)
   $GLOBALS['TL_HOOKS']['getSystemMessages']['myBundle'] = [
       \Acme\MyBundle\EventListener\GetSystemMessagesListener::class, '__invoke'
   ];
   

   // GetSystemMessagesListener.php
   
   namespace Acme\MyBundle\EventListener;
   
   use Acme\AlertReminderBundle\Manager\AlertReminderManager;
   use Acme\RequestBundle\Component\HttpFoundation\Request;
   use Symfony\Contracts\Translation\TranslatorInterface;
   
   class GetSystemMessagesListener
   {
       /**
        * @var TranslatorInterface
        */
       private $translator;
       /**
        * @var Request
        */
       private $request;
       /**
        * @var AlertReminderManager
        */
       private $alertReminderManager;
   
       public function __construct(AlertReminderManager $alertReminderManager, TranslatorInterface $translator, Request $request)
       {
           $this->translator           = $translator;
           $this->request              = $request;
           $this->alertReminderManager = $alertReminderManager;
       }
   
       public function __invoke()
       {
           $message = '<p class="tl_error">My alert message</p>';
   
           return $this->alertReminderManager->prepareSystemMessage($message, 'some_alert_type_alias');
       }
   }
   

public function __invoke(AddAlertsToAlertReminderQueueEvent $event)
{
    if ('alt_issues_existing' !== Input::get('type')) {
        return;
    }

    $messages = $event->getAlerts();

    $messages[] = [
        'class' => 'tl_error', // you can use Contao's tl_ classes
        'message' => 'My message'
    ];

    $event->setAlerts($messages);
}