Commit 7eb6e188 authored by bojanz's avatar bojanz

Add a getLabel() method to StateItem.

parent 9ca565ea
......@@ -249,6 +249,21 @@ class StateItem extends FieldItemBase implements StateItemInterface, OptionsProv
return static::$workflows[$definition_id];
}
/**
* {@inheritdoc}
*/
public function getLabel() {
$label = $this->value;
if ($workflow = $this->getWorkflow()) {
$state = $workflow->getState($this->value);
if ($state) {
$label = $state->getLabel();
}
}
return $label;
}
/**
* {@inheritdoc}
*/
......
......@@ -22,6 +22,14 @@ interface StateItemInterface extends FieldItemInterface {
*/
public function getWorkflow();
/**
* Gets the label of the current state.
*
* @return string
* The label of the current state.
*/
public function getLabel();
/**
* Gets the allowed transitions for the current state.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment