public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $items->getEntity();

    $workflow = $this->moderationInformation->getWorkflowForEntity($entity);
    $default = $items->get($delta)->value ? $workflow->getTypePlugin()->getState($items->get($delta)->value) : $workflow->getTypePlugin()->getInitialState($entity);

    /** @var \Drupal\workflows\Transition[] $transitions */
    $transitions = $this->validator->getValidTransitions($entity, $this->currentUser);

    $transition_labels = [];
    $default_value = NULL;
    foreach ($transitions as $transition) {
      $transition_to_state = $transition->to();
      $transition_labels[$transition_to_state->id()] = $transition_to_state->label();
      if ($default->id() === $transition_to_state->id()) {
        $default_value = $default->id();
      }
    }

    $element = [
      '#type' => 'select',
      '#key_column' => $this->column,
      '#options' => $transition_labels,
      '#default_value' => $default_value,
      '#access' => !empty($transition_labels),
      '#wrapper_attributes' => [
        'class' => ['container-inline'],
      ],
    ];
    $element['#element_validate'][] = [get_class($this), 'validateElement'];

    return $element;
  }
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    
    $entity = $items->getEntity();

    $workflow = $this->moderationInformation->getWorkflowForEntity($entity);
    $default = $items->get($delta)->value ? $workflow->getTypePlugin()->getState($items->get($delta)->value) : $workflow->getTypePlugin()->getInitialState($entity);

    
    $transitions = $this->validator->getValidTransitions($entity, $this->currentUser);

    $transition_labels = [];
    $default_value = NULL;
    foreach ($transitions as $transition) {
      $transition_to_state = $transition->to();
      $transition_labels[$transition_to_state->id()] = $transition_to_state->label();
      if ($default->id() === $transition_to_state->id()) {
        $default_value = $default->id();
      }
    }

    $element = [
      '
      '
      '
      '
      '
      '
        'class' => ['container-inline'],
      ],
    ];
    $element['

    return $element;
  }
public function formElement ( FieldItemListInterface $ items , $ delta , array $ element , array & $ form , FormStateInterface $ form_state ) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $ entity = $ items -> getEntity ( ) ; $ workflow = $ this -> moderationInformation -> getWorkflowForEntity ( $ entity ) ; $ default = $ items -> get ( $ delta ) -> value ? $ workflow -> getTypePlugin ( ) -> getState ( $ items -> get ( $ delta ) -> value ) : $ workflow -> getTypePlugin ( ) -> getInitialState ( $ entity ) ; /** @var \Drupal\workflows\Transition[] $transitions */ $ transitions = $ this -> validator -> getValidTransitions ( $ entity , $ this -> currentUser ) ; $ transition_labels = [ ] ; $ default_value = NULL ; foreach ( $ transitions as $ transition ) { $ transition_to_state = $ transition -> to ( ) ; $ transition_labels [ $ transition_to_state -> id ( ) ] = $ transition_to_state -> label ( ) ; if ( $ default -> id ( ) === $ transition_to_state -> id ( ) ) { $ default_value = $ default -> id ( ) ; } } $ element = [ '#type' => 'select' , '#key_column' => $ this -> column , '#options' => $ transition_labels , '#default_value' => $ default_value , '#access' => ! empty ( $ transition_labels ) , '#wrapper_attributes' => [ 'class' => [ 'container-inline' ] , ] , ] ; $ element [ '#element_validate' ] [ ] = [ get_class ( $ this ) , 'validateElement' ] ; return $ element ; }
{@inheritdoc}
{