You are here

function synonyms_settings_form_submit in Synonyms 7

Submit handler for 'synonyms_settings_form' form.

Store synonyms behavior settings.

File

./synonyms.pages.inc, line 539
Menu page callbacks of Synonyms module.

Code

function synonyms_settings_form_submit($form, &$form_state) {
  foreach ($form_state['values']['settings'] as $behavior => $settings) {
    foreach ($settings as $provider => $behavior_settings) {
      $behavior_implementation = array(
        'entity_type' => $form['settings']['#entity_type'],
        'bundle' => $form['settings']['#bundle'],
        'provider' => $provider,
        'behavior' => $behavior,
        'settings' => isset($behavior_settings['settings']) ? $behavior_settings['settings'] : NULL,
      );
      if ($behavior_settings['enabled']) {
        synonyms_behavior_implementation_save($behavior_implementation);
      }
      else {
        synonyms_behavior_implementation_delete($behavior_implementation);
      }
    }
  }
  drupal_set_message(t('Synonyms settings have been successfully saved.'));
  $form_state['redirect'] = array(
    'admin/structure/synonyms',
  );
}