You are here

public function KanbanWorkflowService::getCurrentStateLabel in Content Planner 8

Gets the label of the current state of a given entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity object.

Return value

bool|string Returns the current state if any, FALSE otherwise.

File

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

Class

KanbanWorkflowService
Class KanbanWorkflowService.

Namespace

Drupal\content_kanban

Code

public function getCurrentStateLabel(ContentEntityInterface $entity) {
  if ($this->moderationInformation
    ->isModeratedEntity($entity)) {
    if ($workflow = $this->moderationInformation
      ->getWorkflowForEntity($entity)) {
      if ($states = self::getWorkflowStates($workflow)) {
        $entity_workflow_state = $this
          ->getCurrentStateId($entity);
        if (array_key_exists($entity_workflow_state, $states)) {
          return $states[$entity_workflow_state];
        }
      }
    }
  }
  return FALSE;
}