You are here

function ds_extras_settings_submit in Display Suite 8.2

Same name and namespace in other branches
  1. 8.4 modules/ds_extras/ds_extras.module \ds_extras_settings_submit()
  2. 8.3 modules/ds_extras/ds_extras.module \ds_extras_settings_submit()
  3. 7.2 modules/ds_extras/includes/ds_extras.admin.inc \ds_extras_settings_submit()
  4. 7 modules/ds_extras/ds_extras.admin.inc \ds_extras_settings_submit()

Submit callback: Extras settings screen.

1 string reference to 'ds_extras_settings_submit'
ds_extras_form_ds_admin_form_alter in modules/ds_extras/ds_extras.module
Implements hook_form_FORM_ID_alter().

File

modules/ds_extras/ds_extras.module, line 292
Display Suite extras main functions.

Code

function ds_extras_settings_submit($form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $extra_fields = array();
  if (!empty($values['fs2']['fields_extra_list'])) {
    $extra_fields = explode("\n", str_replace("\r", '', $values['fs2']['fields_extra_list']));
  }
  $config = \Drupal::configFactory()
    ->getEditable('ds_extras.settings')
    ->set('fields_extra', $values['fs2']['fields_extra'])
    ->set('fields_extra_list', $extra_fields)
    ->set('field_permissions', $values['fs3']['field_permissions'])
    ->set('switch_field', $values['fs3']['switch_field'])
    ->set('hidden_region', $values['fs3']['hidden_region'])
    ->set('override_node_revision', $values['fs3']['override_node_revision'])
    ->set('override_node_revision_view_mode', $values['fs3']['override_node_revision_view_mode']);
  if (\Drupal::moduleHandler()
    ->moduleExists('block')) {
    $config
      ->set('region_to_block', $values['fs3']['region_to_block']);
  }
  $config
    ->save();

  // Mark the router items for rebuild.
  \Drupal::service('router.builder')
    ->setRebuildNeeded();

  // Clear layout plugin caches.
  \Drupal::service('plugin.manager.layout_plugin')
    ->clearCachedDefinitions();
}