You are here

protected function FileStorage::ensureDirectory in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/PhpStorage/FileStorage.php \Drupal\Component\PhpStorage\FileStorage::ensureDirectory()

Ensures the directory exists, has the right permissions, and a .htaccess.

For compatibility with open_basedir, the requested directory is created using a recursion logic that is based on the relative directory path/tree: It works from the end of the path recursively back towards the root directory, until an existing parent directory is found. From there, the subdirectories are created.

Parameters

string $directory: The directory path.

int $mode: The mode, permissions, the directory should have.

2 calls to FileStorage::ensureDirectory()
FileStorage::save in core/lib/Drupal/Component/PhpStorage/FileStorage.php
Saves PHP code to storage.
MTimeProtectedFastFileStorage::save in core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php
Saves PHP code to storage.

File

core/lib/Drupal/Component/PhpStorage/FileStorage.php, line 72

Class

FileStorage
Stores the code as regular PHP files.

Namespace

Drupal\Component\PhpStorage

Code

protected function ensureDirectory($directory, $mode = 0777) {
  if ($this
    ->createDirectory($directory, $mode)) {
    FileSecurity::writeHtaccess($directory);
  }
}