Commit 489cdbcc authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3265632: Fix Errors for messing Enabled entity types and Safe tokens on...

Issue #3265632: Fix Errors for messing Enabled entity types and Safe tokens on the URL aliases settings page
parent 8956e577
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
enabled_entity_types:
  - user
punctuation:
  hyphen: 1
verbose: false
@@ -9,3 +11,10 @@ reduce_ascii: false
case: true
ignore_words: "a, an, as, at, before, but, by, for, from, is, in, into, like, of, off, on, onto, per, since, than, the, this, that, to, up, via, with"
update_action: 2
safe_tokens:
 - alias
 - path
 - join-path
 - login-url
 - url
 - url-brief
+37 −0
Original line number Diff line number Diff line
@@ -113,3 +113,40 @@ function varbase_seo_install() {
    ->applyUpdates();

}

/**
 * Issue #3265632: Fix Errors on Pathauto's settings page.
 */
function varbase_seo_update_90001() {

  // Get editable pathauto settings.
  $pathauto_settings = \Drupal::service('config.factory')->getEditable('pathauto.settings');

  // Add enable entity types if it was notin the pathauto settings in the active site configs.
  $enabled_entity_types = $$pathauto_settings->get('enabled_entity_types');
  if (isset($enabled_entity_types)
    && is_array($enabled_entity_types)
    && !(count($enabled_entity_types) > 0)) {

    $enabled_entity_types = ['user'];
    $pathauto_settings->set('enabled_entity_types', $enabled_entity_types)->save(TRUE);
  }

  // Add the list of safe tokens if it was not in the pathauto settings in the active site configs.
  $safe_tokens = $$pathauto_settings->get('safe_tokens');
  if (isset($safe_tokens)
    && is_array($safe_tokens)
    && !(count($safe_tokens) > 0)) {

    $safe_tokens = [
      'alias',
      'path',
      'join-path',
      'login-url',
      'url',
      'url-brief',
    ];
    $pathauto_settings->set('safe_tokens', $safe_tokens)->save(TRUE);
  }

}