Services/AzineNotifierService.php
public function sendNotificationsFor($recipientId, $wrapperTemplateName, $params)
    {
        // get the recipient
        $recipient = $this->recipientProvider->getRecipient($recipientId);

        // get all Notification-Items for the recipient from the database
        $notifications = $this->getNotificationsFor($recipient);
        if (0 == sizeof($notifications)) {
            return null;
        }

        // get the recipient specific parameters for the twig-templates
        $recipientParams = $this->getRecipientVarsForNotificationsEmail($recipient);
        $params = array_merge($recipientParams, $params);

        // prepare the arrays with template and template-variables for each notification
        $contentItems = array();
        foreach ($notifications as $notification) {
            // decode the $params from the json in the notification-entity
            $itemVars = $notification->getVariables();
            $itemVars = array_merge($params, $itemVars);
            $itemVars['notification'] = $notification;
            $itemVars['recipient'] = $recipient;

            $itemTemplateName = $notification->getTemplate();

            $contentItems[] = array($itemTemplateName => $itemVars);
        }

        // add the notifications to the params array so they will be rendered later
        $params[self::CONTENT_ITEMS] = $contentItems;
        $params['recipient'] = $recipient;
        $params['_locale'] = $recipient->getPreferredLocale();

        $subject = $this->getRecipientSpecificNotificationsSubject($contentItems, $recipient);

        // send the email with the right wrapper-template
        $sent = $this->mailer->sendSingleEmail($recipient->getEmail(), $recipient->getDisplayName(), $subject, $params, $wrapperTemplateName.'.txt.twig', $recipient->getPreferredLocale());

        if ($sent) {
            // save the updated notifications
            $this->setNotificationsAsSent($notifications);

            return null;
        }

        return $recipient->getEmail();
    }
public function sendNotificationsFor($recipientId, $wrapperTemplateName, $params)
    {
        // get the recipient
        $recipient = $this->recipientProvider->getRecipient($recipientId);

        // get all Notification-Items for the recipient from the database
        $notifications = $this->getNotificationsFor($recipient);
        if (0 == sizeof($notifications)) {
            return null;
        }

        // get the recipient specific parameters for the twig-templates
        $recipientParams = $this->getRecipientVarsForNotificationsEmail($recipient);
        $params = array_merge($recipientParams, $params);

        // prepare the arrays with template and template-variables for each notification
        $contentItems = array();
        foreach ($notifications as $notification) {
            // decode the $params from the json in the notification-entity
            $itemVars = $notification->getVariables();
            $itemVars = array_merge($params, $itemVars);
            $itemVars['notification'] = $notification;
            $itemVars['recipient'] = $recipient;

            $itemTemplateName = $notification->getTemplate();

            $contentItems[] = array($itemTemplateName => $itemVars);
        }

        // add the notifications to the params array so they will be rendered later
        $params[self::CONTENT_ITEMS] = $contentItems;
        $params['recipient'] = $recipient;
        $params['_locale'] = $recipient->getPreferredLocale();

        $subject = $this->getRecipientSpecificNotificationsSubject($contentItems, $recipient);

        // send the email with the right wrapper-template
        $sent = $this->mailer->sendSingleEmail($recipient->getEmail(), $recipient->getDisplayName(), $subject, $params, $wrapperTemplateName.'.txt.twig', $recipient->getPreferredLocale());

        if ($sent) {
            // save the updated notifications
            $this->setNotificationsAsSent($notifications);

            return null;
        }

        return $recipient->getEmail();
    }
public function sendNotificationsFor ( $ recipientId , $ wrapperTemplateName , $ params ) { // get the recipient $ recipient = $ this -> recipientProvider -> getRecipient ( $ recipientId ) ; // get all Notification-Items for the recipient from the database $ notifications = $ this -> getNotificationsFor ( $ recipient ) ; if ( 0 == sizeof ( $ notifications ) ) { return null ; } // get the recipient specific parameters for the twig-templates $ recipientParams = $ this -> getRecipientVarsForNotificationsEmail ( $ recipient ) ; $ params = array_merge ( $ recipientParams , $ params ) ; // prepare the arrays with template and template-variables for each notification $ contentItems = array ( ) ; foreach ( $ notifications as $ notification ) { // decode the $params from the json in the notification-entity $ itemVars = $ notification -> getVariables ( ) ; $ itemVars = array_merge ( $ params , $ itemVars ) ; $ itemVars [ 'notification' ] = $ notification ; $ itemVars [ 'recipient' ] = $ recipient ; $ itemTemplateName = $ notification -> getTemplate ( ) ; $ contentItems [ ] = array ( $ itemTemplateName => $ itemVars ) ; } // add the notifications to the params array so they will be rendered later $ params [ self :: CONTENT_ITEMS ] = $ contentItems ; $ params [ 'recipient' ] = $ recipient ; $ params [ '_locale' ] = $ recipient -> getPreferredLocale ( ) ; $ subject = $ this -> getRecipientSpecificNotificationsSubject ( $ contentItems , $ recipient ) ; // send the email with the right wrapper-template $ sent = $ this -> mailer -> sendSingleEmail ( $ recipient -> getEmail ( ) , $ recipient -> getDisplayName ( ) , $ subject , $ params , $ wrapperTemplateName . '.txt.twig' , $ recipient -> getPreferredLocale ( ) ) ; if ( $ sent ) { // save the updated notifications $ this -> setNotificationsAsSent ( $ notifications ) ; return null ; } return $ recipient -> getEmail ( ) ; }
Send the notifications-email for one recipient.

@param int    $recipientId
@param string $wrapperTemplateName
@param array  $params              array of parameters for this recipient

@return string|null or the failed email addressess
Send the notifications - email for one recipient .