eZ Community » Forums » Discussions » Creating a simple custom workflow event
expandshrink

Thursday 09 December 2010 5:01:18 pm - 13 replies

» Read full tutorial

Introduction

This tutorial will guide you through the development of a simple eZ Publish workflow event. At the end of the tutorial, you should be able to create your own workflow event, configure a workflow that would execute the event and configure workflow triggers in the admin interface.

Note : the PDF version of this tutorial, as well as the downloadable extension are here.

 

Saturday 11 December 2010 9:27:38 am

Hi,

Great tutorial! A very good addition to the online docs, I'm sure this will inspire others when setting up their workflows. It also shows the power of eZ Publish, thanks for this contribution!

-- Robin

Saturday 11 December 2010 6:34:58 pm

There seems to be a small typo on Step 8:

It’s not time to see how to retrieve them.

I guess "not" should have been "now".

Nice tutorial, posting Twitter updates is a perfect use case for workflows!

However, the used process of authorizing eZ Publish to have access to the twitter account looks quite cumbersome to me. I guess it could be made a lot easier by offering a screen for that in the eZ Publish administration interface that starts the full web-based authorization process instead of the out-of-band/PIN code authentication which was not really suitable for this kind of app. A good example of how this is done is the nxc_twitter extension available at http://projects.ez.no/nxc_twitter.

Sunday 12 December 2010 9:29:49 am

Huy,

Good tutorial. Learned a lot from this like how to integrate 3rd party libraries, creating custom wrokflowevents.

Monday 13 December 2010 1:46:56 pm

Hi,

Excellent article which shows the power of workflows and how thing can be easily done with it.

However, I just regret you don't put some examples on how debug thoses workflows, it can be tricky for some people.

Max

maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Wednesday 15 December 2010 1:46:39 pm

There seems to be a small typo on Step 8:

It’s not time to see how to retrieve them.

I guess "not" should have been "now".

Thanks, fixed now.

Nice tutorial, posting Twitter updates is a perfect use case for workflows!

However, the used process of authorizing eZ Publish to have access to the twitter account looks quite cumbersome to me. I guess it could be made a lot easier by offering a screen for that in the eZ Publish administration interface that starts the full web-based authorization process instead of the out-of-band/PIN code authentication which was not really suitable for this kind of app. A good example of how this is done is the nxc_twitter extension available at http://projects.ez.no/nxc_twitter.

I agree here, although it is not exactly the scope of this already thorough tutorial. It could be a follow-up tutorial, showing how to create custom panels and tabs in the admin interface ? Easy, yet very useful.

Cheers Kristof,

Wednesday 15 December 2010 1:50:29 pm

Thank you all for the feedbacks. Very much appreciate it.

@Kristof, I've notified Nicolas to see if the typo can be corrected. Regarding the Twitter API you are correct, this is not the easiest way to handle this and NXC technique is sweet. But this allows one to also discover eZ Script.

@maxime, I usually debug my workflows with eZLog::write() which is used here.

Wednesday 28 September 2011 12:59:25 pm

Nice article! It helps me to develop my custom eventtype class happy.gif Emoticon

Can anybody describe how to use STATUS_DEFERRED_TO_CRON?

I'm trying to use next code in my 'execute' function:

if( $process->attribute( 'status' ) == eZWorkflow::STATUS_DEFERRED_TO_CRON ) {
   //do something
    return eZWorkflowType::STATUS_ACCEPTED;
} else {
    return eZWorkflowType::STATUS_DEFERRED_TO_CRON;
}

What I'm doing wrong? Should I use STATUS_DEFERRED_TO_CRON_REPEAT instead?

Friday 30 September 2011 4:37:17 pm

What I'm doing wrong? Should I use STATUS_DEFERRED_TO_CRON_REPEAT instead?

UPD

 if( $process->attribute( 'status' ) == eZWorkflow::STATUS_DEFERRED_TO_CRON ) {
   //do something
    return eZWorkflowType::STATUS_ACCEPTED;
} else {
    return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
}

This code works fine in some cases.

But my custom event was running by multiplexer event and I have used some "tricks" to check the process status

I think the tutorial like 'How to run wokflow events as cronjobs' can help other developers in the future happy.gif Emoticon Can anybody write it?

Modified on Friday 30 September 2011 4:38:52 pm by Sergiy Gedeon

Monday 03 October 2011 3:02:13 pm

Hello Sergey, and thanks for sharing your findings.

About the "How to run wokflow events as cronjobs" tutorial, is that something you would like to write yourself ?

Cheers !

PS : guidelines for writing a tutorial are presented here : http://share.ez.no/learn/write-a-tutorial-win-an-award

Modified on Monday 03 October 2011 3:02:53 pm by Nicolas Pastorino

Thursday 06 October 2011 1:24:35 pm

Hi Sergy

Thanks for the comments and sharing.

I once used this, to defer all processing to the cronjob for tasks that can take a while if done on publishing:

 if(!isset($parameters['in_cronjob'])) {
    eZLog::write("Deferring to cronjob.");
    $db =& eZDB::instance();
    $db->begin();
    $parameters['in_cronjob'] = true;
    $process->setParameters($parameters);
    $process->store();
    $db->commit();
    return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
} else {
    eZLog::write("Running from cronjob.");
}

Modified on Thursday 06 October 2011 1:33:24 pm by Quoc-Huy NGUYEN DINH

Sunday 11 December 2011 9:56:19 pm

 

Now lets proceed with the authorization to modify your Twitter feed, change to the directory ~/extension/mytwitter/lib/ and run...

Running setup.php from this directory did not work for me. The script has to be run from ezpublish rootdir. (Worked for me)

Friday 09 November 2012 5:29:09 pm

Hi,

Perfect Tutorial ,thanks for the same ,and I have problem,my common log seems like follows but ,my twitter accounts not getting any tweet ,please advice me !

[ Nov 09 2012 17:04:26 ] Entering eztwitter workflow

[ Nov 09 2012 17:04:26 ] Credentials found in mytwitter.ini

[ Nov 09 2012 17:04:26 ] Found twitter status attribute

[ Nov 09 2012 17:04:26 ] twitter status attribute not empty

[ Nov 09 2012 17:04:27 ] Twitter status updated:  XXXXXXXXXX XXXXXXX

[ Nov 09 2012 17:04:27 ] Resetting twitter status attribute

Monday 31 December 2012 2:43:52 pm

in my Opinion this tutorial is the BEST tutorial in eZ History !

Even though I did not use exact functionality of this Workflow but I learned a lot from this tutorial

 

Thanks ! 

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from