send notification with all comment in one notification
Exception if error happens
@param $subscriber
@param $contentObject
@param $commentList comment list to the subscriber, which can be null.
@param $tpl
@return void
502398
public function sendNotificationInOne( $subscriber, $contentObject, $commentList = null, $tpl = null )
    {
         if ( is_null( $tpl ) )
         {
             $tpl = eZTemplate::factory();
         }
         $tpl->setVariable( 'subscriber', $subscriber );
         $tpl->setVariable( 'contentobject', $contentObject );
         if ( !is_null( $commentList ) )
         {
            $tpl->setVariable( 'comment_list', $commentList );
         }
         $subject = $tpl->fetch( $this->multiSubjectTemplatePath );
         $body = $tpl->fetch( $this->multiBodyTemplatePath );
         $this->executeSending( $subject, $body, $subscriber );
    }
1216522
public function augment(SubscriptionNotification $notification)
	{
		$this->in  = $notification->in;
		$this->out = $notification->out;
	}
718565
public function sendCommentSpamRequestMail( $comment, $updatePath ) {

		$siteName		= $this->coreProperties->getSiteName();
		$fromEmail		= $this->mailProperties->getSenderEmail();
		$fromName		= $this->mailProperties->getSenderName();
		$contactEmail	= $this->mailProperties->getContactEmail();

		// Send Mail
		$this->getMailer()->compose( self::MAIL_COMMENT_SPAM_REQUEST, [ 'coreProperties' => $this->coreProperties, 'comment' => $comment, 'updatePath' => $updatePath ] )
			->setTo( $contactEmail )
			->setFrom( [ $fromEmail => "$fromName | $siteName" ] )
			->setSubject( "Spam Request | " . $this->coreProperties->getSiteName() )
			//->setTextBody( "heroor" )
			->send();
	}
74318
static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) {
        if (it == null) {
            error(s, new NullPointerException("The iterator is null"));
            return;
        }

        boolean b;

        try {
            b = it.hasNext();
        } catch (Throwable e) {
            error(s, e);
            return;
        }

        if (!b) {
           complete(s);
            return;
        }

        s.onSubscribe(new IterableSubscription<T>(s, it));

    }
242709
public function notificationTemplate($comment, $recipient)
    {
        $template = $this->owner->config()->default_notification_template;

        $this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient);

        return $template;
    }
1297279
public static function sendActivationEmail( $contentObject, $subscriber, $subscription )
    {
        $transport = eZNotificationTransport::instance( 'ezmail' );

        $email = $subscriber->attribute( 'email' );
        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'contentobject', $contentObject );
        $tpl->setVariable( 'subscriber', $subscriber );
        $tpl->setVariable( 'subscription', $subscription );
        $mailSubject = $tpl->fetch( 'design:comment/notification_activation_subject.tpl' );
        $mailBody = $tpl->fetch( 'design:comment/notification_activation_body.tpl' );
        $parameters = array();
        $ezcommentsINI = eZINI::instance( 'ezcomments.ini' );
        $mailContentType = $ezcommentsINI->variable( 'NotificationSettings', 'ActivationMailContentType' );
        $parameters['from'] = $ezcommentsINI->variable( 'NotificationSettings', 'MailFrom' );
        $parameters['content_type'] = $mailContentType;

        $result = $transport->send( array( $email ), $mailSubject, $mailBody, null, $parameters );
        return $result;
    }
720973
public function notificationSubject($comment, $recipient)
    {
        $subject = $this->owner->config()->default_notification_subject;

        $this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient);

        return $subject;
    }
793264
public function notificationSender($comment, $recipient)
    {
        $sender = $this->owner->config()->default_notification_sender;

        // Do hostname substitution
        $host = isset($_SERVER['HTTP_HOST'])
            ? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST'])
            : 'localhost';
        $sender = preg_replace('/{host}/', $host, $sender);

        $this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient);

        return $sender;
    }
325807
public void publish(final Notification notification) {
        LOGGER.debug("Dispatching notification: " + notification.getClass().toString());
        final ArrayList<Subscription> subscriptions = SUBSCRIPTION_MAP.get(notification.getClass());
        if (subscriptions == null) {
            LOGGER.debug("No subscribers to inform from notification: " + notification.getClass().getName());
            return;
        }
        for (final Subscription subscription: subscriptions) {
            if (subscription.getScope() != null && subscription.getGroup() != null && subscription.getLevel() != null) { // subscription was the most specific
                if (subscription.getScope().equals(notification.getScope()) && subscription.getGroup().equals(notification.getGroup()) && subscription.getLevel() == notification.getLevel()) {
                    alertSubscriber(notification, subscription.getSubscriber());
                }
            } else if (subscription.getGroup() != null && subscription.getLevel() != null) { // subscription was very specific
                if (subscription.getGroup().equals(notification.getGroup()) && subscription.getLevel() == notification.getLevel()) {
                    alertSubscriber(notification, subscription.getSubscriber());
                }
            } else if (subscription.getGroup() != null) { // subscription was somewhat specific
                if (subscription.getGroup().equals(notification.getGroup())) {
                    alertSubscriber(notification, subscription.getSubscriber());
                }
            } else if (subscription.getLevel() != null) { // subscription was somewhat specific
                if (subscription.getLevel() == notification.getLevel()) {
                    alertSubscriber(notification, subscription.getSubscriber());
                }
            } else { // subscription was not specific
                alertSubscriber(notification, subscription.getSubscriber());
            }
        }
    }
471066
private function logChange($contentType, $contentId, $newContent = null, $oldContent = null, $comment = null)
    {
        $type = $oldContent ? 'Update' : 'Insert';

        $this->loggerChange->info(
            $type . ' record',
            [
                'action'      => strtoupper($type),
                'contenttype' => $contentType,
                'id'          => $contentId,
                'new'         => $newContent ? $newContent->toArray() : null,
                'old'         => $oldContent ? $oldContent->toArray() : null,
                'comment'     => $comment,
            ]
        );
    }
510639
public function dispatchEvent(String $eventId, $subscriber=null)
	{
		if (isset(EventManager::$listeners[$eventId])) {
			foreach(EventManager::$listeners[$eventId] as $listener) {
				call_user_func_array($listener, [$subscriber]);
			}
		}
	}
942083
public void subscribe(final Class<? extends Notification> notificationClass, final Subscription subscription) {
        if (!SUBSCRIPTION_MAP.containsKey(notificationClass)) {
            SUBSCRIPTION_MAP.put(notificationClass, new ArrayList<>());
        }
        final ArrayList<Subscription> subscriptions = SUBSCRIPTION_MAP.get(notificationClass);
        if (!subscriptions.contains(subscription)) {
            subscriptions.add(subscription);
        }
    }
1070522
@Override
    public void sendNotification(NotificationContext notificationContext) {
        SystemAssert.requireArgument(notificationContext != null, "Notification context cannot be null.");

        Map<String, String> additionalFields = new HashMap<>();

        additionalFields.put("Notification status", "Notification created.");
        _createAnnotation(notificationContext, additionalFields);
        sendAdditionalNotification(notificationContext);
        _dispose();
    }
614528
private void storeWithSubscribers(final List<LogLineTableEntity> lines)
	{
		synchronized (subscribers)
		{
			if (subscribers.isEmpty())
				return; // No subscribers, ignore call

			for (LogSubscriber subscriber : subscribers)
			{
				subscriber.append(lines);
			}

			if (System.currentTimeMillis() > nextSubscriberPurge)
			{
				purgeIdleSubscribers();

				nextSubscriberPurge = System.currentTimeMillis() + purgeSubscriberInterval.getMilliseconds();
			}
		}
	}
1108429
public static function subscribe($event, $type, $entity) {

		if (!$entity instanceof Comment) {
			return;
		}

		$original_container = $entity->getOriginalContainer();
		if (!$original_container instanceof \ElggObject) {
			// Let core subscriptions deal with it
			return;
		}

		if (check_entity_relationship($entity->owner_guid, 'comment_tracker_unsubscribed', $original_container->guid)) {
			// User unsubscribed from notifications about this container
			return;
		}

		add_entity_relationship($entity->owner_guid, 'comment_subscribe', $original_container->guid);
	}
406993
public function addSubscriber(SubscriberInterface $subscriber)
    {
        foreach ($subscriber->getSubscriberEvents() as $subscriberEvent => $params) {
            if (is_string($params)) {
                $this->addListener($subscriberEvent, array($subscriber, $params));
            }

            if (is_array($params)) {
                foreach ($params as $param) {
                    $this->addListener($subscriberEvent, array($subscriber, $param));
                }
            }
        }
    }
385958
public function getListSubscriber($list, $subscriber)
	{
		$result = $this->client->get("lists/{$list}/subscribers/{$subscriber}");
		return $result ? new Resources\Subscriber($this, $result) : null;
	}