Skip to content
Snippets Groups Projects

Issue #3508027 by grimreaper: Do not override existing config on install

1 file
+ 6
2
Compare changes
  • Side-by-side
  • Inline
+ 6
2
@@ -11,7 +11,10 @@ use Drupal\Core\Routing\RequestHelper;
* Implements hook_install().
*/
function robotstxt_install() {
$content = '';
$config = \Drupal::configFactory()->getEditable('robotstxt.settings');
if ($config->get('content')) {
return;
}
// List of candidates for import.
$files = [
@@ -20,6 +23,7 @@ function robotstxt_install() {
\Drupal::service('extension.list.module')->getPath('robotstxt') . '/robots.txt',
];
$content = '';
foreach ($files as $file) {
if (file_exists($file) && is_readable($file)) {
$content = file_get_contents($file);
@@ -27,7 +31,7 @@ function robotstxt_install() {
}
}
\Drupal::configFactory()->getEditable('robotstxt.settings')->set('content', $content)->save();
$config->set('content', $content)->save();
}
/**
Loading