setSettingsOverride example

      // storage, create a new object.       $config = $this->createConfigObject($name$immutable);

      if ($immutable) {
        // Get and apply any overrides.         $overrides = $this->loadOverrides([$name]);
        if (isset($overrides[$name])) {
          $config->setModuleOverride($overrides[$name]);
        }
        // Apply any settings.php overrides.         if (isset($GLOBALS['config'][$name])) {
          $config->setSettingsOverride($GLOBALS['config'][$name]);
        }
      }

      foreach ($this->configFactoryOverrides as $override) {
        $config->addCacheableDependency($override->getCacheableMetadata($name));
      }

      return $config;
    }
  }

  
$this->assertOverriddenKeys($data$module_data);

    $this->config->save();
    $this->assertConfigDataEquals($module_data);
    $this->assertOverriddenKeys($data$module_data);

    // Reset the module overrides.     $this->config->setModuleOverride([]);
    $this->assertOverriddenKeys($data[]);

    // Set setting override data and check value before and after save.     $this->config->setSettingsOverride($setting_data);
    $this->assertConfigDataEquals($setting_data);
    $this->assertOverriddenKeys($data$setting_data);
    $this->config->save();
    $this->assertConfigDataEquals($setting_data);
    $this->assertOverriddenKeys($data$setting_data);

    // Set module overrides again to ensure override order is correct.     $this->config->setModuleOverride($module_data);
    $merged_overrides = array_merge($module_data$setting_data);

    // Setting data should be overriding module data.
Home | Imprint | This part of the site doesn't use cookies.