You are here

public function WorkflowTransition::dpm in Workflow 8

Helper/debugging function. Shows simple contents of Transition.

Parameters

string $function:

Overrides WorkflowTransitionInterface::dpm

File

src/Entity/WorkflowTransition.php, line 1113

Class

WorkflowTransition
Implements an actual, executed, Transition.

Namespace

Drupal\workflow\Entity

Code

public function dpm($function = '') {
  $transition = $this;
  $entity = $transition
    ->getTargetEntity();
  $time = \Drupal::service('date.formatter')
    ->format($transition
    ->getTimestamp());

  // Do this extensive $user_name lines, for some troubles with Action.
  $user = $transition
    ->getOwner();
  $user_name = $user ? $user
    ->getAccountName() : 'unknown username';
  $t_string = $this
    ->getEntityTypeId() . ' ' . $this
    ->id() . ' for workflow_type <i>' . $this
    ->getWorkflowId() . '</i> ' . ($function ? "in function '{$function}'" : '');
  $output[] = 'Entity  = ' . $this
    ->getTargetEntityTypeId() . '/' . ($entity ? $entity
    ->bundle() . '/' . $entity
    ->id() : '___/0');
  $output[] = 'Field   = ' . $transition
    ->getFieldName();
  $output[] = 'From/To = ' . $transition
    ->getFromSid() . ' > ' . $transition
    ->getToSid() . ' @ ' . $time;
  $output[] = 'Comment = ' . $user_name . ' says: ' . $transition
    ->getComment();
  $output[] = 'Forced  = ' . ($transition
    ->isForced() ? 'yes' : 'no') . '; ' . 'Scheduled = ' . ($transition
    ->isScheduled() ? 'yes' : 'no');
  if (function_exists('dpm')) {

    // In Workflow->dpm().
    dpm($output, $t_string);

    // In Workflow->dpm().
  }

  // In Workflow->dpm().
}