You are here

function varbase_assemble_development_tools in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.8

Same name and namespace in other branches
  1. 8.4 varbase.profile \varbase_assemble_development_tools()
  2. 8.5 varbase.profile \varbase_assemble_development_tools()
  3. 8.6 varbase.profile \varbase_assemble_development_tools()
  4. 8.7 varbase.profile \varbase_assemble_development_tools()
  5. 9.0.x varbase.profile \varbase_assemble_development_tools()

Batch job to assemble Varbase extra components.

Parameters

array $install_state: The current install state.

Return value

array The batch job definition.

File

./varbase.profile, line 262
Enables modules and site configuration for a Varbase site installation.

Code

function varbase_assemble_development_tools(array &$install_state) {
  $batch = [];

  // Install selected Development tools.
  $selected_development_tools = [];
  $selected_development_configs = [];
  if (isset($install_state['varbase']['development_tools_values'])) {
    $selected_development_tools = $install_state['varbase']['development_tools_values'];
  }
  if (isset($install_state['varbase']['development_tools_configs'])) {
    $selected_development_configs = $install_state['varbase']['development_tools_configs'];
  }

  // Development tools.
  $developmentTools = ConfigBit::getList('configbit/development.tools.varbase.bit.yml', 'show_development_tools', TRUE, 'dependencies', 'profile', 'varbase');

  // If we do have development tools and we have selected development tools.
  if (count($selected_development_tools) && count($developmentTools)) {

    // Have batch processes for each selected development tool.
    foreach ($selected_development_tools as $development_tool_key => $development_tool_checked) {
      if ($development_tool_checked) {

        // If the development tool was a module and not enabled, then enable it.
        if (!\Drupal::moduleHandler()
          ->moduleExists($development_tool_key)) {

          // Add checked development tool to the batch process to be enabled.
          $batch['operations'][] = [
            'varbase_assemble_extra_component_then_install',
            (array) $development_tool_key,
          ];
        }
        if (count($selected_development_configs) && isset($developmentTools[$development_tool_key]['config_form']) && $developmentTools[$development_tool_key]['config_form'] == TRUE && isset($developmentTools[$development_tool_key]['formbit'])) {
          $formbit_file_name = drupal_get_path('profile', 'varbase') . '/' . $developmentTools[$development_tool_key]['formbit'];
          if (file_exists($formbit_file_name)) {

            // Added the selected development configs to the batch process
            // with the same function name in the formbit.
            $batch['operations'][] = [
              'varbase_save_editable_config_values',
              (array) [
                $development_tool_key,
                $formbit_file_name,
                $selected_development_configs,
              ],
            ];
          }
        }
      }
    }

    // Hide Wornings and status messages.
    $batch['operations'][] = [
      'varbase_hide_warning_and_status_messages',
      (array) TRUE,
    ];

    // Fix entity updates to clear up any mismatched entity.
    $batch['operations'][] = [
      'varbase_fix_entity_update',
      (array) TRUE,
    ];
  }
  return $batch;
}