You are here

function node_revisions_autoclean_update_8001 in Node Revisions Autoclean 8

Sets -1 where node_revisions_autoclean is set to 0.

File

./node_revisions_autoclean.install, line 20
Contains node_revisions_autoclean.install.

Code

function node_revisions_autoclean_update_8001() {

  /* @var $nodeTypes NodeType[] */
  $nodeTypes = NodeType::loadMultiple();
  $config = \Drupal::configFactory()
    ->getEditable('node_revisions_autoclean.settings');
  foreach ($nodeTypes as $nodeType) {
    if ($config
      ->get(sprintf('node.%s', $nodeType
      ->id())) == '0') {
      $config
        ->set(sprintf('node.%s', $nodeType
        ->id()), -1)
        ->save(TRUE);
    }
  }
}