1 path.module path_taxonomy_form_vocabulary_submit($form, &$form_state)

Submit handler for taxonomy_form_vocabulary().

File

core/modules/path/path.module, line 329
Enables users to customize URLs and provide automatic URL alias patterns.

Code

function path_taxonomy_form_vocabulary_submit($form, &$form_state) {
  if (isset($form_state['values']['path_pattern'])) {
    $config = config('path.settings');
    $pattern_type = 'taxonomy_term_' . $form['#vocabulary']->machine_name . '_pattern';
    $pattern = trim($form_state['values']['path_pattern']);
    $generic_pattern = $config->get('taxonomy_term_pattern');

    // Don't save the specific pattern if it matches the general pattern.
    if ($pattern && $pattern !== $generic_pattern) {
      $config->set($pattern_type, $pattern);
    }
    else {
      // If the specific pattern matches the general pattern or is empty delete
      // the specific pattern.
      $config->clear($pattern_type);
      if (empty($pattern)) {
        backdrop_set_message(t('The <em>Default URL alias pattern</em> field was left empty, so the generic pattern of <code>@pattern</code> will still be used. This can be changed on the <a href="!url">URL alias patterns</a> page.', array('@pattern' => $generic_pattern, '!url' => url('admin/config/urls/path/patterns'))));
      }
    }
    $config->save();
  }
}