Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
When you deal with the new config system (see https://drupal.org/node/1500260 for more information), you should access properties with \Drupal::config(), rather then config(), which is deprecated.
Before:
$gzip = config('system.performance')->get('response.gzip');
After:
$gzip = \Drupal::config('system.performance')->get('response.gzip');
Note also that in a class you should inject the 'config.factory' service and get the config object from there
class {
public function __construct(ConfigFactory $config_factory) {
$this->config = $config_factory->get('system.performance');
}
public function other() {
$gzip = $this->config->get('response.gzip');
}
}
Impacts:
Module developers