You are here

protected function ConfigInstaller::validateDependencies in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Config/ConfigInstaller.php \Drupal\Core\Config\ConfigInstaller::validateDependencies()

Validates an array of config data that contains dependency information.

Parameters

string $config_name: The name of the configuration object that is being validated.

array $data: Configuration data.

array $enabled_extensions: A list of all the currently enabled modules and themes.

array $all_config: A list of all the active configuration names.

Return value

bool TRUE if the dependencies are met, FALSE if not.

2 calls to ConfigInstaller::validateDependencies()
ConfigInstaller::findDefaultConfigWithUnmetDependencies in core/lib/Drupal/Core/Config/ConfigInstaller.php
Finds default configuration with unmet dependencies.
ConfigInstaller::installOptionalConfig in core/lib/Drupal/Core/Config/ConfigInstaller.php
Installs optional configuration.

File

core/lib/Drupal/Core/Config/ConfigInstaller.php, line 500
Contains \Drupal\Core\Config\ConfigInstaller.

Class

ConfigInstaller

Namespace

Drupal\Core\Config

Code

protected function validateDependencies($config_name, array $data, array $enabled_extensions, array $all_config) {
  if (isset($data['dependencies'])) {
    $all_dependencies = $data['dependencies'];

    // Ensure enforced dependencies are included.
    if (isset($all_dependencies['enforced'])) {
      $all_dependencies = array_merge($all_dependencies, $data['dependencies']['enforced']);
      unset($all_dependencies['enforced']);
    }

    // Ensure the configuration entity type provider is in the list of
    // dependencies.
    list($provider) = explode('.', $config_name, 2);
    if (!isset($all_dependencies['module'])) {
      $all_dependencies['module'][] = $provider;
    }
    elseif (!in_array($provider, $all_dependencies['module'])) {
      $all_dependencies['module'][] = $provider;
    }
    foreach ($all_dependencies as $type => $dependencies) {
      $list_to_check = [];
      switch ($type) {
        case 'module':
        case 'theme':
          $list_to_check = $enabled_extensions;
          break;
        case 'config':
          $list_to_check = $all_config;
          break;
      }
      if (!empty($list_to_check)) {
        $missing = array_diff($dependencies, $list_to_check);
        if (!empty($missing)) {
          return FALSE;
        }
      }
    }
  }
  return TRUE;
}