FileStorage::ensureDirectory

protected FileStorage::ensureDirectory($directory, $mode = 0777)

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.

Return value

bool TRUE if the directory exists or has been created, FALSE otherwise.

File

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

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)) {
    $htaccess_path = $directory . '/.htaccess';
    if (!file_exists($htaccess_path) && file_put_contents($htaccess_path, static::htaccessLines())) {
      @chmod($htaccess_path, 0444);
    }
  }
}
doc_Drupal
2016-10-29 09:13:40
Comments
Leave a Comment

Please login to continue.