/** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { $row['to']['#markup'] = $this->stateStorage->load($entity->getToState())->label(); $row['label'] = $entity->label(); $row['roles']['#markup'] = implode(', ', user_role_names(FALSE, 'use ' . $entity->id() . ' transition')); return $row + parent::buildRow($entity); }
/** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { /** @var ModerationStateTransitionInterface $entity */ $row['label'] = $entity->label(); $row['id']['#markup'] = $entity->id(); $row['from']['#markup'] = $this->stateStorage->load($entity->getFromState())->label(); $row['to']['#markup'] = $this->stateStorage->load($entity->getToState())->label(); return $row + parent::buildRow($entity); }
/** * {@inheritdoc} * * @todo D8-port: add D7-theming to TransitionListBuilder. */ public function buildRow(EntityInterface $transition) { // Show the history table. $current_themed = FALSE; /* @var $transition WorkflowTransitionInterface */ $entity = $transition->getTargetEntity(); $field_name = $transition->getFieldName(); $current_sid = workflow_node_current_state($entity, $field_name); $to_state = $transition->getToState(); if (!$to_state) { // This is an invalid/deleted state. $to_label = WORKFLOW_MARK_STATE_IS_DELETED; // Add a footer to explain the addition. $this->footer_needed = TRUE; } else { $label = Html::escape($this->t($to_state->label())); if ($transition->getToSid() == $current_sid && $to_state->isActive() && !$current_themed) { $to_label = $label; if (!$current_themed) { // Make a note that we have themed the current state; other times in the history // of this entity where the entity was in this state do not need to be specially themed. $current_themed = TRUE; } } elseif (!$to_state->isActive()) { $to_label = $label . WORKFLOW_MARK_STATE_IS_DELETED; // Add a footer to explain the addition. $this->footer_needed = TRUE; } else { // Regular state. $to_label = $label; } } unset($to_state); // Not needed anymore. $from_state = $transition->getFromState(); if (!$from_state) { // This is an invalid/deleted state. $from_label = WORKFLOW_MARK_STATE_IS_DELETED; // Add a footer to explain the addition. $this->footer_needed = TRUE; } else { $label = Html::escape($this->t($from_state->label())); if (!$from_state->isActive()) { $from_label = $label . WORKFLOW_MARK_STATE_IS_DELETED; // Add a footer to explain the addition. $this->footer_needed = TRUE; } else { // Regular state. $from_label = $label; } } unset($from_state); // Not needed anymore. $owner = $transition->getOwner(); $field_name = $transition->getFieldName(); $field_label = $transition->getFieldName(); $variables = array('transition' => $transition, 'extra' => '', 'from_label' => $from_label, 'to_label' => $to_label, 'user' => $owner); // Allow other modules to modify the row. \Drupal::moduleHandler()->alter('workflow_history', $variables); // 'class' => array('workflow_history_row'), // TODO D8-port $row['timestamp']['data'] = $transition->getTimestampFormatted(); // 'class' => array('timestamp') // html_entity_decode() transforms chars like '&' correctly. if ($this->showColumnFieldname($entity)) { $row['field_name']['data'] = html_entity_decode($field_label); } $row['from_state']['data'] = html_entity_decode($from_label); // 'class' => array('previous-state-name')) $row['to_state']['data'] = html_entity_decode($to_label); // 'class' => array('state-name')) $row['user_name']['data'] = $owner->getUsername(); // 'class' => array('user-name') $row['comment']['data'] = html_entity_decode($transition->getComment()); // 'class' => array('log-comment') // $row['comment'] = array( // '#type' => 'textarea', // '#default_value' => $transition->getComment(), // ); // Column 'Operations' is now added by core. // D7: $row['operations']['data'] = $this->buildOperations($entity); $row += parent::buildRow($transition); return $row; }