partytown_drupal-1.0.5/partytown_drupal.install
partytown_drupal.install
<?php
/**
* @file
* The install file for partytown_drupal.
*
* This file includes module updates, install hooks, and patches.
*/
/**
* Updates the forward shema key to include a new "preserve_behavior" key.
*/
function partytown_drupal_update_111001() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('partytown_drupal.settings');
$forward_config = $config->get('forward');
$new_forwards = [];
if (!empty($forward_config)) {
$value = preg_replace('/\\r/', '', $forward_config);
$new_forwards = explode(PHP_EOL, $value);
foreach ($new_forwards as $key => $forward) {
$forward_with_preserve = [
"function" => $forward,
"preserve_behavior" => FALSE,
];
$new_forwards[$key] = $forward_with_preserve;
}
}
if (!empty($new_forwards)) {
$config->set('forward', $new_forwards);
$config->save(TRUE);
}
}
