You are here

function type_style_form_alter in Type Style 8

Implements hook_form_alter().

File

./type_style.module, line 17
Hook implementations for the Type Style module.

Code

function type_style_form_alter(array &$form, FormStateInterface $form_state) {
  $form_object = $form_state
    ->getFormObject();
  if (!$form_object instanceof EntityForm) {
    return;
  }
  $entity = $form_object
    ->getEntity();
  $entity_support = \Drupal::moduleHandler()
    ->invokeAll('type_style_entity_support');
  if (!$entity instanceof ConfigEntityBundleBase && !in_array($entity
    ->getEntityTypeId(), $entity_support)) {
    return;
  }
  $label = $entity
    ->getEntityType()
    ->getLabel();
  $settings = $entity
    ->getThirdPartySettings('type_style');
  type_style_attach_to_form($form, $settings, $label);
  $form['#entity_builders'][] = 'type_style_entity_builder';
  \Drupal::moduleHandler()
    ->alter('type_style_form', $form, $entity);
}