You are here

function comment_ajax_pager_settings_submit in Comments ajax pager 8

1 string reference to 'comment_ajax_pager_settings_submit'
comment_ajax_pager_form_alter in ./comment_ajax_pager.module
Implements hook_form_alter().

File

./comment_ajax_pager.module, line 75

Code

function comment_ajax_pager_settings_submit($form, $form_state) {
  if (!empty($form['#entity'])) {
    $values = $form_state
      ->getValues();
    $entity = $form['#entity'];
    $entityTypeId = $entity
      ->getEntityTypeId();
    $bundle = $entity
      ->bundle();
    $field_name = $form['default_value']['widget']['#field_name'];
    $config = \Drupal::configFactory()
      ->getEditable('comment_ajax_pager.settings');
    $OldSettings = \Drupal::config('comment_ajax_pager.settings')
      ->get('settings');
    if (empty($OldSettings)) {
      $OldSettings = [];
    }
    $OldSettings[$entityTypeId][$bundle][$field_name] = $values['settings']['load_more'];
    $config
      ->set('settings', $OldSettings);
    $config
      ->save();
  }
}