Introduction
The Workflow Orchestration API provided by the Gravity_Flow_API class is the starting point for interaction with a local installation. Here are some examples of things you can do with the API:
Sample Code
Add workflow steps to a form
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | $api = new Gravity_Flow_API( $form_id ); // Basic settings for an Approval Step $settings = array ( 'step_name' => 'Approval' , 'description' => '' , 'step_type' => 'approval' , 'feed_condition_logic_conditional_logic' => false, 'feed_condition_conditional_logic_object' => array (), 'type' => 'select' , 'assignees' => array ( 'user_id|1' ), 'routing' => array (), 'unanimous_approval' => false, 'assignee_notification_enabled' => false, 'assignee_notification_message' => 'A new entry is pending your approval' , 'destination_complete' => 'next' , 'destination_rejected' => 'complete' , 'destination_approved' => 'next' , ); $api ->add_step( $settings ); |
Get all the steps for a form
1 2 3 | $api = new Gravity_Flow_API( $form_id ); /* @var Gravity_Flow_Step[] $steps */ $steps = $api ->get_steps(); |
Get the current step
1 2 3 4 5 6 | $api = new Gravity_Flow_API( $form_id ); /* @var Gravity_Flow_Step $step @var array() $entry The Entry */ $step = $api ->get_current_step( $entry ); |
Check the current workflow status of an entry
1 2 3 4 5 6 | $api = new Gravity_Flow_API( $form_id ); /* @var array() $entry The Entry @var string $status The current status of the entry. */ $status = $api ->get_status( $entry ); |
Cancel a workflow
1 2 3 4 5 6 | $api = new Gravity_Flow_API( $form_id ); /* @var array() $entry The Entry @var bool $success True for success. False if not currently in a workflow. */ $status = $api ->cancel_workflow( $entry ); |
Restart a workflow
1 2 3 4 5 | $api = new Gravity_Flow_API( $form_id ); /* @var array() $entry The Entry */ $api ->restart_workflow( $entry ); |
Restart a step
1 2 3 4 5 | $api = new Gravity_Flow_API( $form_id ); /* @var array() $entry The Entry */ $api ->restart_step( $entry ); |
Send an entry to a different step
1 2 3 4 5 6 | $api = new Gravity_Flow_API( $form_id ); /* @var array() $entry The Entry @var int $ste_id The ID of the destination Step */ $api ->send_to_step( $entry , $step_id ); |