ibexa

Path

ez publish / technical manual / 5.x / features / notifications / notification handlers


Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.

  • Notification handlers

    There are several handlers that process notification events. The following handlers are known to the eZ Publish system by default:

    • Subtree notification
    • General digest
    • Collaboration notification

    Subtree notification

    The "ezsubtree" notification handler processes "ezpublish" events.

    General digest

    The "ezgeneraldigest" notification handler processes "ezcurrenttime" events.

    Collaboration notification

    The "ezcollaborationnotification" notification handler processes "ezcollaboration" events.

    The built-in notification handlers are stored in the "kernel/classes/notification/handler/" directory. It is possible to extend the system by creating custom notification handlers for special needs.

    Processing the notification events

    Whenever the "eznotificationeventfilter.php" script is executed, the system will try to run every unhandled notification event with every available notification handler.

    Please note that handling one event may result in sending/generating more than one notification. For example, if a new version of an article is published, all the subscribed users will be notified.

    If every notification is sent successfully, the event will be deleted from the database. Otherwise, if some of the generated notifications must be delayed in order to form a daily/weekly/monthly digest, the system will add new notification items to the user collection. A notification item contains data about the notification event, its handler, subscriber e-mail and time when this notification must be sent.

    The digest handler starts processing the "ezcurrenttime" event by accessing the collection of notification items. The time specified in the "ezcurrenttime" event will be compared with the time of each notification item in order to determine which items that must be handled at the moment. As long as each notification item contains data on the notification event and its handler, the system will process this event with the right handler. The resulting notifications will be collected into digest messages and sent to the subscribers.

    If the notification item was handled successfully, this item will be removed from the collection. If none of the remaining notification items reference the handled notification event, this event will be deleted from the database.

    The "ezcurrenttime" event will be deleted from the database when processing is completed. Please note that processing the "ezcurrenttime" event by the digest handler does not always result in sending/generating digest notifications (for example, if none of the subscribers has chosen the digest mode for notifications).

    Settings

    The "[NotificationEventHandlerSettings]" section of the " notification.ini" configuration file defines the event handlers that will respond to the notification event. Under this section, the following settings can be specified:

    The "RepositoryDirectories[]" array specifies the directories where eZ Publish will search for built in notification handlers. The exact location of the handler in the directory is specified using the "AvailableNotificationEventTypes" setting.

    The "ExtensionDirectories[]" array specifies the extension directories where eZ Publish will search for additional notification handlers. By default eZ Publish will search in the "notification/handler/" subdirectory inside your extension. The exact location of the handler in this subdirectory is specified using the "AvailableNotificationEventTypes" setting.

    The "AvailableNotificationEventTypes[]" array contains a list of handlers.

    Example 1

    The following lines can be specified in the " notification.ini" configuration file:

    [NotificationEventHandlerSettings]
    RepositoryDirectories[]=kernel/classes/notification/handler/
    ExtensionDirectories[]
    AvailableNotificationEventTypes[]=ezgeneraldigest
    AvailableNotificationEventTypes[]=ezcollaborationnotification
    AvailableNotificationEventTypes[]=ezsubtree
    

    These settings will make eZ Publish search for the following files for built in notification handlers.

    • kernel/classes/notification/handler/ezgeneraldigest/ezgeneraldigesthandler.php
    • kernel/classes/notification/handler/ezcollaborationnotification/ezcollaborationnotificationhandler.php
    • kernel/classes/notification/handler/ezsubtree/ezsubtreehandler.php

    Example 2

    You can extend the system by creating custom notification handlers. For example, if you have an extension "nExt" that includes a notification handler "nh" put the following lines into an override for the " notification.ini" configuration file:

    [NotificationEventHandlerSettings]
    ExtensionDirectories[]=nExt
    AvailableNotificationEventTypes[]=nh
    

    or

    [NotificationEventHandlerSettings]
    RepositoryDirectories[]=extension/nExt/notification/handler/
    AvailableNotificationEventTypes[]=nh
    

    These settings will make eZ Publish expect the additional notification handler to be located at "extension/nExt/notification/handler/nh/nhhandler.php"

    Svitlana Shatokhina (14/09/2010 11:50 am)

    Geir Arne Waaler (29/09/2010 6:57 am)


    Comments

    There are no comments.