I have a config.ini.php file as follows :
;<?php
;die(); // For further security
; // These php lines are used to hide the data from the browser
; // They are both valid php and valid ini files
;/*
; Don't forget to disable and reenable module, after adjusting the values
[folders]
var_1= "value1"
var_2 = "value2"
And in module_name.install file, I am using it as follows.
/**
* Implementation of hook_enable().
*/
function module_name_enable() {
$config_file = 'config.ini.php';
$parameters = parse_ini_file($config_file);
foreach ($parameters as $key => $value) {
\Drupal::state()->set($key, $value);
\Drupal::config('module_name.settings')
->set($key, $value)
->save();
}
}
I then try to use a variable with the following code.
$getvar = \Drupal::config('module_name.settings')
->get('var_1');
\Drupal::state()->get('var_1', '');
I am not getting the value. What am I doing wrong?