You are here

protected function ConfigBit::targetConfigExpectedNotToHave in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.8

Same name and namespace in other branches
  1. 9.0.x src/Config/ConfigBit.php \Drupal\varbase\Config\ConfigBit::targetConfigExpectedNotToHave()

Check target config expected not to have.

Parameters

array $config_action: The config action.

array $target_config_data: The target config data.

1 call to ConfigBit::targetConfigExpectedNotToHave()
ConfigBit::expectedTargetConfig in src/Config/ConfigBit.php
Check expected target config.

File

src/Config/ConfigBit.php, line 505

Class

ConfigBit
Class ConfigBit.

Namespace

Drupal\varbase\Config

Code

protected function targetConfigExpectedNotToHave(array $config_action, array $target_config_data) {
  $target_config_expected_not_to_have = TRUE;
  if (isset($config_action['target_config_expected_not_to_have'])) {

    // Computes the difference of arrays with additional index check.
    // containing all the values from [target config expected NOT to
    // have] that are not present in [target config data] .
    // ----------------------------------------------------------------------.
    // Wild card exption not to have in all listed configs.
    if (isset($config_action['expected_config_wild_card'])) {
      $wild_card_configs = $this->configFactory
        ->listAll($config_action['expected_config_wild_card']);
      foreach ($wild_card_configs as $wild_card_name) {
        $wild_card_factory = $this->configFactory
          ->getEditable($wild_card_name);
        $wild_card_data = $wild_card_factory
          ->get($config_action['target_config_path']);
        $wild_card_expected_not_to_have_diff = DiffArray::diffAssocRecursive($config_action['target_config_expected_not_to_have'], $wild_card_data);
        if (isset($wild_card_expected_not_to_have_diff) && count($wild_card_expected_not_to_have_diff) == 0) {
          $target_config_expected_not_to_have = FALSE;
          break;
        }
      }
    }
    else {
      $expected_not_to_have_diff = DiffArray::diffAssocRecursive($config_action['target_config_expected_not_to_have'], $target_config_data);
      if (isset($expected_not_to_have_diff) && count($expected_not_to_have_diff) == 0) {
        $target_config_expected_not_to_have = FALSE;
      }
    }
  }
  return $target_config_expected_not_to_have;
}