You are here

node_revisions_autoclean.install in Node Revisions Autoclean 8

File

node_revisions_autoclean.install
View source
<?php

/**
 * @file
 * Contains node_revisions_autoclean.install.
 */
use Drupal\node\Entity\NodeType;

/**
 * Implements hook_uninstall().
 */
function node_revisions_autoclean_uninstall() {
  \Drupal::configFactory()
    ->getEditable('node_revisions_autoclean.settings')
    ->delete();
}

/**
 * Sets -1 where node_revisions_autoclean is set to 0.
 */
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);
    }
  }
}

Functions

Namesort descending Description
node_revisions_autoclean_uninstall Implements hook_uninstall().
node_revisions_autoclean_update_8001 Sets -1 where node_revisions_autoclean is set to 0.