You are here

public function KanbanWorkflowService::getWorkflowStateHistory in Content Planner 8

Gets the workflow state history of a given entity.

Parameters

string $workflow_id: A string representing the workflow id.

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity for which the workflow history is requested.

Return value

array An array with the workflow state history for the given entity.

1 call to KanbanWorkflowService::getWorkflowStateHistory()
KanbanWorkflowService::getPreviousWorkflowStateId in modules/content_kanban/src/KanbanWorkflowService.php
Get ID of the previous workflow state.

File

modules/content_kanban/src/KanbanWorkflowService.php, line 209

Class

KanbanWorkflowService
Class KanbanWorkflowService.

Namespace

Drupal\content_kanban

Code

public function getWorkflowStateHistory($workflow_id, ContentEntityInterface $entity) {
  $query = $this->database
    ->select('content_moderation_state_field_revision', 'r');
  $query
    ->addField('r', 'moderation_state');
  $query
    ->condition('r.workflow', $workflow_id);
  $query
    ->condition('r.content_entity_type_id', $entity
    ->getEntityTypeId());
  $query
    ->condition('r.content_entity_id', $entity
    ->id());
  $query
    ->orderBy('r.revision_id', 'DESC');
  $result = $query
    ->execute()
    ->fetchAll();
  $return = [];
  foreach ($result as $row) {
    $return[] = $row->moderation_state;
  }
  return $return;
}