Last active
March 12, 2017 08:18
-
-
Save woutersf/a304fb2d4bf44143e002da45ffc2cfc5 to your computer and use it in GitHub Desktop.
Drupal8 settings and config, override settings in settings.php, variable_get en variable_set
This file contains hidden or 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 | |
// Fetching The data via the container (old variable_get) | |
$data = \Drupal::config('my_module.settings')->get('my_setting_name'); | |
// Fetching the data via the Settings class | |
use Drupal\Core\Site\Settings; | |
$settings = Settings::get('http_client_config'); | |
$data = $settings['my_setting_name']; | |
// Old variable_set saving the configuration | |
\Drupal::configFactory()->getEditable('my_module.settings')->set('my_setting_name', $new_val)->save(); | |
// Override the setting in the settings.php file | |
$config['my_module.settings']['my_setting_name'] = "The data"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment