eZ Community » Forums » Discussions » Tip: custom workflow operation triggers
expandshrink

Friday 07 October 2011 7:02:41 pm - 8 replies

» Read full blog post

Introduction

You may already know that ez comes with a bunch of default workflow operation triggers, like content->publish, in this post I will show how to create a custom one for your own modules, so users will be able to execute pieces of codes before/after certain module code (or eZ Publish cli script, cronjob, template operator, fetch function...), then they won't need to hack your module code for that, it will be necessary only create a separated event extension. 

Friday 07 October 2011 10:15:23 pm

Thiago,

This is really great example!

I regularly hear of folks looking to create custom triggers for various needs.

Now I have a simple example to link them all to in the future.

Thanks again for everything you do so very well!

 

Cheers,

Heath

Saturday 08 October 2011 1:46:42 am

@Heath

Thanks! Lately I'm not having time to elaborate a complete tutorial, so I'm posting these mini-tutorials/tips as blog posts, keeping it as simple as possible, the focus here is just the main idea, not a real use case, anyway, I'm trying to do my best, I'm glad you enjoyed this.

Saturday 08 October 2011 8:39:37 pm

This is a really nice tutorial. I was personally not aware that we could do this in our custom extensions. Thanks a lot!

Sunday 09 October 2011 3:59:38 am

Custom triggers are fantastic customization point for those looking to do new things.

Workflow event programming has become a personal favorite of mine over the many years it's been available within eZ Publish.

If you have not learned about this feature yet, a vast treasure trove of possibilities await you!

Take it eZ!

cheers,
//kracker

THEME: Kreayshawn - Bumpin Bumpin ( Instrumental )

Sunday 09 October 2011 4:12:19 am

Can anyone tell me if it is possible to call custom module trigger (like the ones described in the above example) within an eZ Publish cli script, cronjob, template operator, fetch function?

What are the usage limitations here?

It seems like (i've not tested this yet) the workflow event system with custom triggers can be used in a lot more than just within module views...

 

best wishes

Sunday 09 October 2011 1:26:25 pm

Can anyone tell me if it is possible to call custom module trigger (like the ones described in the above example) within an eZ Publish cli script, cronjob, template operator, fetch function?

What are the usage limitations here?

It seems like (i've not tested this yet) the workflow event system with custom triggers can be used in a lot more than just within module views...

 

best wishes

Yeah, it's possible to use it anywhere (and I edited the blog post):

...
    if (eZOperationHandler::operationIsAvailable( 'yourmodule_view' )) {
    
        eZOperationHandler::execute( 'yourmodule', 'view', array( 'param1' => 'a',
                                                               'param2' => 'b' ) );
    } else {
       YourModuleOperationCollection::helloView('a','b');
    } 
...

Modified on Sunday 09 October 2011 1:31:12 pm by Thiago Campos Viana

Thursday 15 December 2011 12:45:53 pm

If i understand trigger operation the idea is to fire automatically some action when a trigger is called ?

This can be interesting but what if you only want to create a custom trigger that doesn't start any "built-in" operations but that start a classical workflow ?

For example i created a custom trigger (which appears in "Admin -> Triggers"blunk.gif Emoticon associated with a workflow.

Then i try to make some module start this trigger which is then supposed to engage associated workflow with this line :

 eZWorkflowType::setTriggerTypes(array('mymodule' => array('response' => array('after'))));

But this does nothing.

Does anyone knows process to start a trigger from php ?

To get back to operations : Is defining operations mandatory when declaring a custom trigger ?

What if you only use this trigger to start a workflow ?

Modified on Thursday 15 December 2011 12:50:07 pm by H-Works Agency

Thursday 15 December 2011 1:18:39 pm

If i understand trigger operation the idea is to fire automatically some action when a trigger is called ?

This can be interesting but what if you only want to create a custom trigger that doesn't start any "built-in" operations but that start a classical workflow ?

For example i created a custom trigger (which appears in "Admin -> Triggers"blunk.gif Emoticon associated with a workflow.

Then i try to make some module start this trigger which is then supposed to engage associated workflow with this line :

 eZWorkflowType::setTriggerTypes(array('mymodule' => array('response' => array('after'))));

But this does nothing.

Does anyone knows process to start a trigger from php ?

To get back to operations : Is defining operations mandatory when declaring a custom trigger ?

What if you only use this trigger to start a workflow ?

Ok got it this is the code :

$operationResult = eZTrigger::runTrigger('post_response' , 'mymodule', 'response', array('order_id' => 342));

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from