You are here

public function StateItem::getWorkflow in State Machine 8

Gets the workflow used by the field.

Return value

\Drupal\state_machine\Plugin\Workflow\WorkflowInterface|false The workflow, or FALSE if unknown at this time.

Overrides StateItemInterface::getWorkflow

7 calls to StateItem::getWorkflow()
StateItem::applyDefaultValue in src/Plugin/Field/FieldType/StateItem.php
Applies the default value.
StateItem::applyTransitionById in src/Plugin/Field/FieldType/StateItem.php
Applies a transition with the given ID, changing the current state.
StateItem::dispatchTransitionEvent in src/Plugin/Field/FieldType/StateItem.php
Dispatches a transition event for the given phase.
StateItem::getAllowedStates in src/Plugin/Field/FieldType/StateItem.php
Gets the next allowed states for the given field value.
StateItem::getPossibleOptions in src/Plugin/Field/FieldType/StateItem.php
Returns an array of possible values with labels for display.

... See full list

File

src/Plugin/Field/FieldType/StateItem.php, line 241

Class

StateItem
Plugin implementation of the 'state' field type.

Namespace

Drupal\state_machine\Plugin\Field\FieldType

Code

public function getWorkflow() {
  if ($callback = $this
    ->getSetting('workflow_callback')) {
    $workflow_id = call_user_func($callback, $this
      ->getEntity());
  }
  else {
    $workflow_id = $this
      ->getSetting('workflow');
  }
  if (empty($workflow_id)) {
    return FALSE;
  }
  $workflow_manager = \Drupal::service('plugin.manager.workflow');
  return $workflow_manager
    ->createInstance($workflow_id);
}