You are here

function Workflow::delete in Workflow 7

Same name and namespace in other branches
  1. 7.2 includes/Entity/Workflow.php \Workflow::delete()

Given a wid, delete the workflow and its data.

@deprecated: workflow_delete_workflows_by_wid() --> Workflow::delete(). @todo: This function does NOT delete WorkflowStates.

File

includes/Entity/Workflow.php, line 178
Contains workflow\includes\Entity\Workflow.

Class

Workflow
@file Contains workflow\includes\Entity\Workflow.

Code

function delete() {
  $wid = $this->wid;

  // Notify any interested modules before we delete, in case there's data needed.
  module_invoke_all('workflow', 'workflow delete', $wid, NULL, NULL, FALSE);

  // Delete associated state (also deletes any associated transitions).
  foreach ($this
    ->getStates($all = TRUE) as $state) {
    $state
      ->deactivate($new_sid = 0);
    $state
      ->delete();
  }

  // Delete type map. @todo: move this to hook_workflow of workflownode.module.
  if (TRUE || module_exists('workflownode')) {
    workflow_delete_workflow_type_map_by_wid($wid);
  }

  // Delete the workflow.
  db_delete('workflows')
    ->condition('wid', $wid)
    ->execute();
}