W3cubDocs

/Drupal 8

protected function ConfigInstaller::validateDependencies

protected ConfigInstaller::validateDependencies($config_name, array $data, array $enabled_extensions, array $all_config)

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.

File

core/lib/Drupal/Core/Config/ConfigInstaller.php, line 513

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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!ConfigInstaller.php/function/ConfigInstaller::validateDependencies/8.1.x