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.

eZ debug

Timing: Jan 18 2025 00:02:02
Script start
Timing: Jan 18 2025 00:02:02
Module start 'layout'
Timing: Jan 18 2025 00:02:02
Module start 'content'
Timing: Jan 18 2025 00:02:02
Module end 'content'
Timing: Jan 18 2025 00:02:02
Script end

Main resources:

Total runtime0.0896 sec
Peak memory usage6,144.0000 KB
Database Queries42

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 589.4844152.6406
Module start 'layout' 0.00560.0035 742.125039.5000
Module start 'content' 0.00910.0791 781.6250362.1172
Module end 'content' 0.08820.0014 1,143.742215.7031
Script end 0.0896  1,159.4453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00293.2619150.0002
Check MTime0.00121.2983150.0001
Mysql Total
Database connection0.00070.749810.0007
Mysqli_queries0.033437.2651420.0008
Looping result0.00030.2953400.0000
Template Total0.058264.920.0291
Template load0.00212.308320.0010
Template processing0.056162.616820.0281
Template load and register function0.00010.108310.0001
states
state_id_array0.00121.366710.0012
state_identifier_array0.00131.487220.0007
Override
Cache load0.00171.9146240.0001
Sytem overhead
Fetch class attribute name0.00212.331430.0007
class_abstraction
Instantiating content class attribute0.00000.010130.0000
General
dbfile0.00070.7309100.0001
String conversion0.00000.010140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplblog_entry/full.tplextension/community_design/design/suncana/override/templates/blog_entry/full.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
4content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezkeyword.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezkeyword.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 9

Time used to render debug report: 0.0002 secs