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

Submit handler for node type form.

File

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

Code

function path_node_type_form_submit($form, &$form_state) {
  if (isset($form_state['values']['path_pattern'])) {
    $config = config('path.settings');
    $pattern_type = 'node_' . $form_state['values']['type'] . '_pattern';
    $pattern = trim($form_state['values']['path_pattern']);
    $generic_pattern = $config->get('node_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) && !empty($generic_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();
  }
}