public function KanbanWorkflowService::getPreviousWorkflowStateId in Content Planner 8
Get ID of the previous workflow state.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity object.
Return value
string Returns the previous state id.
1 call to KanbanWorkflowService::getPreviousWorkflowStateId()
- KanbanWorkflowService::onEntityPresave in modules/
content_kanban/ src/ KanbanWorkflowService.php - Acts upon a entity presave.
File
- modules/
content_kanban/ src/ KanbanWorkflowService.php, line 184
Class
- KanbanWorkflowService
- Class KanbanWorkflowService.
Namespace
Drupal\content_kanbanCode
public function getPreviousWorkflowStateId(ContentEntityInterface $entity) {
$workflow = $this->moderationInformation
->getWorkflowForEntity($entity);
if ($state_history = $this
->getWorkflowStateHistory($workflow
->id(), $entity)) {
if (isset($state_history[0])) {
return $state_history[0];
}
}
$state = $workflow
->getTypePlugin()
->getInitialState($entity);
return $state
->id();
}