You are here

protected function FileStorage::ensureStorage in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Config/FileStorage.php \Drupal\Core\Config\FileStorage::ensureStorage()

Check if the directory exists and create it if not.

1 call to FileStorage::ensureStorage()
FileStorage::write in core/lib/Drupal/Core/Config/FileStorage.php
Writes configuration data to the storage.

File

core/lib/Drupal/Core/Config/FileStorage.php, line 78

Class

FileStorage
Defines the file storage.

Namespace

Drupal\Core\Config

Code

protected function ensureStorage() {
  $dir = $this
    ->getCollectionDirectory();
  $success = $this
    ->getFileSystem()
    ->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);

  // Only create .htaccess file in root directory.
  if ($dir == $this->directory) {
    $success = $success && FileSecurity::writeHtaccess($this->directory);
  }
  if (!$success) {
    throw new StorageException('Failed to create config directory ' . $dir);
  }
  return $this;
}