validateDependencies example


        catch (ConfigNameException $e) {
          $message = $this->t('The config name @config_name is invalid.', ['@config_name' => $name]);
          $event->getConfigImporter()->logError($message);
        }
      }
    }
    $config_importer = $event->getConfigImporter();
    if ($config_importer->getStorageComparer()->getSourceStorage()->exists('core.extension')) {
      $this->validateModules($config_importer);
      $this->validateThemes($config_importer);
      $this->validateDependencies($config_importer);
    }
    else {
      $config_importer->logError($this->t('The core.extension configuration does not exist.'));
    }
  }

  /** * Validates module installations and uninstallations. * * @param \Drupal\Core\Config\ConfigImporter $config_importer * The configuration importer. */
    $dependency_manager = new ConfigDependencyManager();
    $dependency_manager->setData($config_to_create);
    $config_to_create = array_merge(array_flip($dependency_manager->sortAll())$config_to_create);
    if (!empty($dependency)) {
      // In order to work out dependencies we need the full config graph.       $dependency_manager->setData($this->getActiveStorages()->readMultiple($existing_config) + $config_to_create);
      $dependencies = $dependency_manager->getDependentEntities(key($dependency)reset($dependency));
    }

    foreach ($config_to_create as $config_name => $data) {
      // Remove configuration where its dependencies cannot be met.       $remove = !$this->validateDependencies($config_name$data$enabled_extensions$all_config);
      // Remove configuration that is not dependent on $dependency, if it is       // defined.       if (!$remove && !empty($dependency)) {
        $remove = !isset($dependencies[$config_name]);
      }

      if ($remove) {
        // Remove from the list of configuration to create.         unset($config_to_create[$config_name]);
        // Remove from the list of all configuration. This ensures that any         // configuration that depends on this configuration is also removed.
Home | Imprint | This part of the site doesn't use cookies.