Change record status: 
Project: 
Introduced in branch: 
11.5.x
Introduced in version: 
11.5.0
Description: 

The class \Drupal\Core\Config\FileStorageFactory is deprectated. The only method on the class getSync() is replaced by the config.storage.sync service.

To work with the configuration sync directory use the config.storage.sync service. This service is not new and sites can begin using it before updating to 11.5.0.

Using the sync storage service ensures any configuration for modules or themes that are not installed will be able to use constants and enums from these modules. Read the companion change record to learn how to write constants and Enums in a yaml file

As part of this change, if the config.storage.sync service is altered to or decorated by another class and reads config data from YAML sources other than the configuration sync directory, the FileStorage object reading the config data should be wrapped in a Drupal\Core\Config\AutoloadingStorage object. AutoloadingStorage should also wrap any FileStorage objects doing similar things in code handling the ConfigEvents::STORAGE_TRANSFORM_IMPORT event.

Example

Before

use Drupal\Core\Config\FileStorage;

// ...

  public function foo(): void {
    $storage = new FileStorage('path/to/additional/yaml_directory');
    $data = $storage->read('my.config.name');
  }

// ...

After

use Drupal\Core\Config\FileStorage;
use Drupal\Core\Config\SyncFactory;

// ...

  // Note the 'Drupal\Core\Config\SyncFactory' service must be injected because it is private.
  public function __construct(
    protected readonly SyncFactory $syncFactory,
  ) {}

// ...

  public function foo(): void {
    $storage = new FileStorage('path/to/additional/yaml_directory');
    $wrappedStorage = $this->syncFactory->wrapStorageWithAutoloadingStorage($storage);
    $data = $wrappedStorage->read('my.config.name');
  }

// ...
Impacts: 
Module developers