You are here

function node_modules_uninstalled in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/node.module \node_modules_uninstalled()

Implements hook_modules_uninstalled().

File

core/modules/node/node.module, line 1265
The core module that allows content to be submitted to the site.

Code

function node_modules_uninstalled($modules) {

  // Remove module-specific settings from all node types.
  $config_names = \Drupal::configFactory()
    ->listAll('node.type.');
  foreach ($config_names as $config_name) {
    $config = \Drupal::config($config_name);
    $changed = FALSE;
    foreach ($modules as $module) {
      if ($config
        ->get('settings.' . $module)) {
        $config
          ->clear('settings.' . $module);
        $changed = TRUE;
      }
    }
    if ($changed) {
      $config
        ->save();
    }
  }

  // Check whether any of the disabled modules implemented hook_node_grants(),
  // in which case the node access table needs to be rebuilt.
  foreach ($modules as $module) {

    // At this point, the module is already disabled, but its code is still
    // loaded in memory. Module functions must no longer be called. We only
    // check whether a hook implementation function exists and do not invoke it.
    // Node access also needs to be rebuilt if language module is disabled to
    // remove any language-specific grants.
    if (!node_access_needs_rebuild() && (\Drupal::moduleHandler()
      ->implementsHook($module, 'node_grants') || $module == 'language')) {
      node_access_needs_rebuild(TRUE);
    }
  }

  // If there remains no more node_access module, rebuilding will be
  // straightforward, we can do it right now.
  if (node_access_needs_rebuild() && count(\Drupal::moduleHandler()
    ->getImplementations('node_grants')) == 0) {
    node_access_rebuild();
  }
}