You are here

config_actions.module in Config Actions 8

Contains main module logic and hooks for config actions.

File

config_actions.module
View source
<?php

/**
 * @file
 * Contains main module logic and hooks for config actions.
 */
use Drupal\config_actions\ConfigActionsServiceInterface;

/**
 * Implements hook_modules_installed().
 *
 * Execute any config actions in the installed module.
 * @param $modules
 */
function config_actions_modules_installed($modules) {
  if (\Drupal::isConfigSyncing()) {

    // Don't run config actions when enabling module during a config import.
    return;
  }
  foreach ($modules as $module_name) {
    $action_dir = DRUPAL_ROOT . '/' . drupal_get_path('module', $module_name) . '/' . ConfigActionsServiceInterface::CONFIG_ACTIONS_CONFIG_DIR;
    if (is_dir($action_dir)) {
      $configActions = \Drupal::service('config_actions');

      // Enable autoExecute mode to skip any actions marked with "auto:false"
      $configActions
        ->autoExecute(TRUE);
      $configActions
        ->importAction($module_name);
    }
  }
}

Functions