You are here

public static function WorkflowManager::getWorkflowTransitionForm in Workflow 8

Gets the TransitionWidget in a form (for e.g., Workflow History Tab)

Parameters

\Drupal\Core\Entity\EntityInterface $entity:

string $field_name:

array $form_state_additions:

Return value

array The form.

Overrides WorkflowManagerInterface::getWorkflowTransitionForm

4 calls to WorkflowManager::getWorkflowTransitionForm()
WorkflowDefaultFormatter::viewElements in src/Plugin/Field/FieldFormatter/WorkflowDefaultFormatter.php
N.B. A large part of this function is taken from CommentDefaultFormatter.
WorkflowDefaultWidget::formElement in src/Plugin/Field/FieldWidget/WorkflowDefaultWidget.php
Be careful: Widget may be shown in very different places. Test carefully!!
WorkflowTransitionBlock::build in src/Plugin/Block/WorkflowTransitionBlock.php
Builds and returns the renderable array for this block plugin.
WorkflowTransitionListController::historyOverview in src/Controller/WorkflowTransitionListController.php
Shows a list of an entity's state transitions, but only if WorkflowHistoryAccess::access() allows it.

File

src/Entity/WorkflowManager.php, line 354

Class

WorkflowManager
Manages entity type plugin definitions.

Namespace

Drupal\workflow\Entity

Code

public static function getWorkflowTransitionForm(EntityInterface $entity, $field_name, array $form_state_additions = []) {

  // Create a transition, to pass to the form. No need to use setValues().
  $current_sid = workflow_node_current_state($entity, $field_name);
  $transition = WorkflowTransition::create([
    $current_sid,
    'field_name' => $field_name,
  ]);
  $transition
    ->setTargetEntity($entity);

  // Create the WorkflowTransitionForm.

  /** @var \Drupal\Core\Entity\EntityFormBuilder $entity_form_builder */
  $entity_form_builder = \Drupal::getContainer()
    ->get('entity.form_builder');
  $form = $entity_form_builder
    ->getForm($transition, 'add', $form_state_additions);
  return $form;
}