Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

With RAD: a workflow event

The Workflow event wizard writes an event type that logs every publication: triggers and statuses, the generated class and templates, and the one method to fill in.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/extension-development/part-3-extension-developer/tutorials/rad-workflow-event.md

On this page

With RAD: a workflow event

Tutorial 5. The Workflow event wizard (/setup/workflowevent) writes a workflow event type: the class, its registration, the templates the workflow editor shows, and, if you ask for them, settings per event stored in the columns eZWorkflowEvent provides. The output below was produced by the wizard's generator (expWorkflowEventWizard::files()); every PHP file passed php -l, and the generated class was created with eZWorkflowType::createType() and asked isAllowed() with the kernel loaded.

1. The form

FieldValue
Extension namemysite_hello
Event identifiermysitepublishlog
Name in the workflow editorLog publishing
Triggerscontent / publish / after
Statuses it can returnSTATUS_ACCEPTED

The wizard lists only triggers that exist (from the operation definitions) and always keeps STATUS_ACCEPTED: as its code says, "An event with no way to say it is done would hang every workflow it is put in". Settings per event, if you add any, are mapped onto the four integer and five text columns of eZWorkflowEvent; one that cannot get a column is dropped "rather than silently sharing".

2. The files

.gitignore
LICENSE
README.md
composer.json
design/standard/templates/workflow/eventtype/edit/event_mysitepublishlog.tpl
design/standard/templates/workflow/eventtype/view/event_mysitepublishlog.tpl
eventtypes/event/mysitepublishlog/mysitepublishlogtype.php
extension.xml
ezinfo.php
settings/design.ini.append.php
settings/workflow.ini.append.php

The registration:

[EventSettings]
ExtensionDirectories[]=mysite_hello
AvailableEventTypes[]=event_mysitepublishlog

The class (comments removed):

<?php
class mysitepublishlogType extends eZWorkflowEventType
{
    const WORKFLOW_TYPE_STRING = 'mysitepublishlog';

    public function __construct()
    {
        parent::__construct( self::WORKFLOW_TYPE_STRING,
                             ezpI18n::tr( 'kernel/workflow/event', 'Log publishing' ) );
        $this->setTriggerTypes( array(
            'content' => array(
                'publish' => array( 'after' ) ) ) );
    }

    function execute( $process, $event )
    {
        $parameters = $process->attribute( 'parameter_list' );
        if ( isset( $parameters['object_id'] ) )
        {
            $object = eZContentObject::fetch( $parameters['object_id'] );
            if ( !$object instanceof eZContentObject )
            {
                eZDebug::writeNotice( 'Object ' . $parameters['object_id'] . ' is gone; nothing to do.',
                                      __METHOD__ );
                return eZWorkflowType::STATUS_ACCEPTED;
            }
        }
        return eZWorkflowType::STATUS_ACCEPTED;
    }
}

eZWorkflowEventType::registerEventType( mysitepublishlogType::WORKFLOW_TYPE_STRING, 'mysitepublishlogType' );

The templates are in design/standard, so the workflow editor finds them in any administration design.

3. Fill in execute()

Add the work where the object is known:

eZLog::write( sprintf( 'Published object %d version %d: %s',
                       (int)$parameters['object_id'], (int)$parameters['version'], $object->attribute( 'name' ) ),
              'mysite_hello.log' );

4. Switch it on and use it

./console exp:ini add 'site.ini/ExtensionSettings/ActiveExtensions[]' mysite_hello global
php bin/php/ezpgenerateautoloads.php -e
php bin/php/ezcache.php --clear-all

Setup > Workflows: create a workflow with the event "Log publishing"; Setup > Triggers: connect it to content / publish / after. Publish an article and read var/log/mysite_hello.log.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x