You are here

function acquia_contenthub_form_node_type_form_alter in Acquia Content Hub 8

Implements hook_form_FORM_ID_alter().

File

./acquia_contenthub.module, line 170
Contains acquia_contenthub.module.

Code

function acquia_contenthub_form_node_type_form_alter(array &$form, FormStateInterface &$form_state) {
  $node_type = $form_state
    ->getFormObject()
    ->getEntity()
    ->id();

  /** @var \Drupal\acquia_contenthub\EntityManager $entity_manager */
  $entity_manager = \Drupal::service('acquia_contenthub.entity_manager');

  /** @var \Drupal\acquia_contenthub\Entity\ContentHubEntityTypeConfig $entity_type_config */
  $entity_type_config = $entity_manager
    ->getContentHubEntityTypeConfigurationEntity('node');

  // Only enable selection of preview images for entities that have been
  // previously selected to work with Acquia Content Hub.
  if (!empty($entity_type_config) && $entity_type_config
    ->isEnableIndex($node_type)) {
    $form['acquia_contenthub'] = \Drupal::service('acquia_contenthub.form.node_type_preview_image_form')
      ->getForm($node_type);
    $form['actions']['submit']['#submit'][] = 'acquia_contenthub_form_node_type_form_submit';
  }
}