You are here

function type_style_moderation_form_workflow_state_edit_form_alter in Type Style 8

Implements hook_form_FORM_ID_alter().

File

modules/type_style_moderation/type_style_moderation.module, line 21
Hook implementations for the Type Style Moderation module.

Code

function type_style_moderation_form_workflow_state_edit_form_alter(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\content_moderation\ContentModerationState $state */
  $state = $form_state
    ->get('state');
  $state_id = $state
    ->id();

  /** @var \Drupal\workflows\WorkflowInterface $workflow */
  $workflow = $form_state
    ->getFormObject()
    ->getEntity();
  $type_plugin = $workflow
    ->getTypePlugin();
  $config = $type_plugin
    ->getConfiguration();
  $settings = isset($config['states'][$state_id]['type_style']) ? $config['states'][$state_id]['type_style'] : [];
  type_style_attach_to_form($form, $settings, 'State');
  array_splice($form['actions']['submit']['#submit'], 1, 0, [
    'type_style_moderation_form_workflow_state_edit_form_submit',
  ]);
}