The Workflow Orchestration API
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:
- Add workflow steps to a form
- Get all the steps for a form
- Get the current step
- Check the current workflow status of an entry
- Cancel a workflow
- Restart a workflow
- Restart a step
- Send an entry to a different step
Sample Code
Add workflow steps to a form
$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
$api = new Gravity_Flow_API( $form_id ); /* @var Gravity_Flow_Step[] $steps */ $steps = $api->get_steps();
Get the current step
$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
$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
$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
$api = new Gravity_Flow_API( $form_id ); /* @var array() $entry The Entry */ $api->restart_workflow( $entry );
Restart a step
$api = new Gravity_Flow_API( $form_id ); /* @var array() $entry The Entry */ $api->restart_step( $entry );
Send an entry to a different step
$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 );