I want to override a custom module configuration in the settings.php
file. So the configuration in database can be independent from the environment.
$config['my_module.settings']['prop'] = 'foo';
I my module configuration form, the config result is different given the method I use to get it :
class MyConfigurationForm extends ConfigFormBase {
public function buildForm( array $form, FormStateInterface $form_state ){
$config = $this->config( 'my_module.settings' );
print_r( $config->get('prop') );
// prints database value, or nothing if there is no value in database for 'prop'
$config = \Drupal::config( 'my_module.settings' );
print_r( $config->get('prop') );
// prints 'foo'
}
}
Why is that ? What's the difference between these two methods ?