Tip: The minimum workflow event extension

Friday 19 August 2011 5:30:06 am

By : Thiago Campos Viana

In this post I will show how to create and setup the minimum workflow event extension.

First create the following structure inside the extension folder:

  • minevent
    • settings
    • eventtypes
      • event
        • minevent

Then we define all the events this extension has by creating the minevent/settings/workflow.ini.append.php file:

<?php
/*

[EventSettings]
ExtensionDirectories[]=minevent
AvailableEventTypes[]=event_minevent

*/
?>

Finally create the minevent/eventtypes/event/minevent/mineventtype.php

<?php

class MinEventType extends eZWorkflowEventType {
    const WORKFLOW_TYPE_STRING = "minevent";

    function MinEventType() {
        $this->eZWorkflowEventType(MinEventType::WORKFLOW_TYPE_STRING, "MinEvent");
        /* define trigger here */
        $this->setTriggerTypes(array('content' => array('publish' => array('after'))));
    }

    function execute($process, $event) {
        /* code goes here */
        echo "Hello Event";
        eZExecution::cleanExit();
        //return eZWorkflowType::STATUS_ACCEPTED;
    }

}

eZWorkflowEventType::registerEventType(MinEventType::WORKFLOW_TYPE_STRING, "MinEventType");
?>

In administrator user interface, click 'setup' tab->'extensions' menu, select 'minevent', click button 'Apply Changes', click button 'Regenerate autoload arrays for extensions'. Clear the cache.

Create the MinEvent workflow: 'Workflows'->'Standard'->'New workflow'->'minevent' ( name MinEvent ).
Setup MinEvent trigger: 'Triggers'-> 'content-publish-after' ( choose MinEvent ). Apply changes.
Go to "Content", edit and publish some content object, you will see the "Hello Event".

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.