Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

Implementation of a filtering hook

In order to implement a filter, you must create a class that extends the "eZAsynchronousPublishingFilter" abstract class.

This class implements the "eZAsynchronousPublishingFilterInterface" interface, and enforces the definition of the "accept()" method. The "accept()" method must return a boolean. "True" means the object can be published asynchronously, while "False" instructs the system to skip the asynchronous publishing feature, and publish the content directly.

The abstract class provides you with the "eZContentObjectVersion" being published, as the "$version" class property. From this property, you can easily test the content object's property (publishing time, author, content class, section), read attributes, and so on.

Example:

    <?php
     ;/**
      * Exclude from asynchronous publishing any object that isn't an article
      * @return bool
      */
     class eZAsynchronousPublishingClassFilter extends eZAsynchronousPublishingFilter
     {
         public function accept()
         {
             $contentObject = $this->version->contentObject();
             return in_array( $contentObject->attribute( 'class_identifier' ), $this->validClasses );
         }
 
         private $validClasses = array( 'article' );
     }
     ?>
 

The class above will only publish asynchronously objects of class article.

Settings

Each filter must be registered using INI settings from content.ini. Below is an example for the class filtering class above:

[PublishingSettings]
AsynchronousPublishingFilters[]=eZAsynchronousPublishingClassFilter

One line similar to the one above must be added for each filter.

Geir Arne Waaler (04/03/2011 12:53 pm)

Geir Arne Waaler (22/03/2011 1:02 pm)


Comments

There are no comments.