You are here

public function WorkflowTransition::dpm in Workflow 7.2

Helper debugging function to easily show the contents fo a transition.

File

includes/Entity/WorkflowTransition.php, line 663
Contains workflow\includes\Entity\WorkflowTransition. Contains workflow\includes\Entity\WorkflowTransitionController.

Class

WorkflowTransition
Implements an actual Transition.

Code

public function dpm($function = '') {
  $transition = $this;
  $entity = $transition
    ->getEntity();
  $entity_type = $transition->entity_type;
  list($entity_id, , $entity_bundle) = $entity ? entity_extract_ids($entity_type, $entity) : array(
    '',
    '',
    '',
  );
  $time = $transition
    ->getTimestampFormatted();

  // Do this extensive $user_name lines, for some troubles with Action.
  $user = $transition
    ->getUser();
  $user_name = $user ? $user->name : 'unknown username';
  $t_string = get_class($this) . ' ' . (isset($this->hid) ? $this->hid : '') . ' ' . ($function ? "in function '{$function}'" : '');
  $output[] = 'Entity  = ' . (!$entity ? 'NULL' : $entity_type . '/' . $entity_bundle . '/' . $entity_id);
  $output[] = 'Field   = ' . $transition
    ->getFieldName();
  $output[] = 'From/To = ' . $transition->old_sid . ' > ' . $transition->new_sid . ' @ ' . $time;
  $output[] = 'Comment = ' . $user_name . ' says: ' . $transition
    ->getComment();
  $output[] = 'Forced  = ' . ($transition
    ->isForced() ? 'yes' : 'no');
  if (function_exists('dpm')) {
    dpm($output, $t_string);
  }
}