W3cubDocs

/Drupal 8

protected function FileStorage::ensureStorage

protected FileStorage::ensureStorage()

Check if the directory exists and create it if not.

File

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

Class

FileStorage
Defines the file storage.

Namespace

Drupal\Core\Config

Code

protected function ensureStorage() {
  $dir = $this->getCollectionDirectory();
  $success = file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  // Only create .htaccess file in root directory.
  if ($dir == $this->directory) {
    $success = $success && file_save_htaccess($this->directory, TRUE, TRUE);
  }
  if (!$success) {
    throw new StorageException('Failed to create config directory ' . $dir);
  }
  return $this;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!FileStorage.php/function/FileStorage::ensureStorage/8.1.x