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
1 2 3 4 5 6 7 8 | 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); } } } |
Please login to continue.