Last active
November 29, 2023 07:06
-
-
Save prashantdsala/e156626d0a4832584e7cefce671c8684 to your computer and use it in GitHub Desktop.
Configuration Override System: https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-override-system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This file will reside in modules/custom/YOURMODULE/src/Config | |
namespace Drupal\custom_event\Config; | |
use Drupal\Core\Cache\CacheableMetadata; | |
use Drupal\Core\Config\ConfigFactoryOverrideInterface; | |
use Drupal\Core\Config\StorageInterface; | |
/** | |
* Example configuration override. | |
*/ | |
class ConfigExampleOverrides implements ConfigFactoryOverrideInterface { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function loadOverrides($names) { | |
$overrides = []; | |
if (in_array('config_split.config_split.development', $names)) { | |
$overrides['config_split.config_split.development'] = ['status' => TRUE]; | |
} | |
return $overrides; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getCacheSuffix() { | |
return 'ConfigExampleOverrider'; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getCacheableMetadata($name) { | |
return new CacheableMetadata(); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) { | |
return NULL; | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
config_example.overrider: | |
class: Drupal\custom_event\Config\ConfigExampleOverrides | |
tags: | |
- {name: config.factory.override, priority: 5} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment