You are here

function template_preprocess_workflow_transition in Workflow 8

Prepares variables for workflow_transition templates.

Default template: workflow-transition.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties and children of the details element. Properties used: #children.

File

./workflow.theme.inc, line 21
Preprocessors for workflow elements.

Code

function template_preprocess_workflow_transition(array &$variables) {

  /** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $workflowTransition */
  $workflowTransition = $variables['elements']['#workflow_transition'];
  $variables['from_state'] = $workflowTransition
    ->getFromState();
  $variables['to_state'] = $workflowTransition
    ->getToState();
  $variables['time'] = $workflowTransition
    ->getTimestampFormatted();
  $variables['user'] = $workflowTransition
    ->getOwner();
  $variables['comment'] = $workflowTransition
    ->getComment();
  $variables['field_attributes'] = new Attribute();
  $variables['label_attributes'] = new Attribute();
  $variables['value_attributes'] = new Attribute();
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
  $variables['attributes']['class'][] = 'workflow-transition';
}