You are here

function drush_config_devel_process_config in Configuration development 8

Exports a list of configuration entities.

Parameters

array $config_list: An array of configuration entities.

string $type: The type of extension we're exporting, one of module or theme.

string $extension: The module, theme or install profile we're exporting.

string $directory: The directory we're exporting to.

Return value

bool TRUE when the configuration was successfully exported. FALSE otherwise.

1 call to drush_config_devel_process_config()
drush_config_devel_export in drush/config_devel.drush.inc
Drush command callback.

File

drush/config_devel.drush.inc, line 163
Configuration development module drush integration.

Code

function drush_config_devel_process_config($config_list, $type, $extension, $directory) {
  $config_path = drupal_get_path($type, $extension) . "/{$directory}";

  // Ensure the directory always exists.
  if (!file_exists($config_path) && !\Drupal::service('file_system')
    ->mkdir($config_path, NULL, TRUE)) {
    drush_set_error('CONFIG_DEVEL_DIRECTORY_NOT_CREATED', sprintf('The %s directory could not be created', $config_path));
    return FALSE;
  }
  foreach ($config_list as $name) {
    $config = \Drupal::config($name);
    $file_names = array(
      $config_path . '/' . $name . '.yml',
    );
    \Drupal::service('config_devel.writeback_subscriber')
      ->writeBackConfig($config, $file_names);
  }
  return TRUE;
}