<?php

/**
 * @file
 * Contains wxt_ext_layout.module.
 */

use Drupal\node\Entity\NodeType;
use Drupal\wxt_translation\TranslationHelper;

/**
 * Implements hook_install().
 */
function wxt_ext_workflow_install() {
  // Stop here during a config sync.
  if (Drupal::isConfigSyncing()) {
    return;
  }

  $modules = [
    'autosave_form',
  ];
  $modules = array_filter($modules, [Drupal::moduleHandler(), 'moduleExists']);
  if ($modules) {
    wxt_ext_workflow_modules_installed($modules);
  }

  foreach (NodeType::loadMultiple() as $node_type) {
    wxt_ext_workflow_node_type_insert($node_type);
  }

  // Install config translations.
  $moduleHandler = \Drupal::service('module_handler');
  if ($moduleHandler->moduleExists('wxt_translation')) {
    TranslationHelper::importTranslations('wxt_ext_workflow');
  }
}
