function FileSecurity::writeHtaccess
Same name in this branch
- 11.1.x composer/Plugin/VendorHardening/FileSecurity.php \Drupal\Composer\Plugin\VendorHardening\FileSecurity::writeHtaccess()
Writes an .htaccess file in the given directory, if it doesn't exist.
Parameters
string $directory: The directory.
bool $deny_public_access: (optional) Set to FALSE to ensure an .htaccess file for an open and public directory. Default is TRUE.
bool $force: (optional) Set to TRUE to force overwrite an existing file.
Return value
bool TRUE if the file already exists or was created. FALSE otherwise.
4 calls to FileSecurity::writeHtaccess()
- FileStorage::ensureDirectory in core/
lib/ Drupal/ Component/ PhpStorage/ FileStorage.php - Ensures the directory exists, has the right permissions, and a .htaccess.
- FileStorage::ensureStorage in core/
lib/ Drupal/ Core/ Config/ FileStorage.php - Check if the directory exists and create it if not.
- HtaccessWriter::write in core/
lib/ Drupal/ Core/ File/ HtaccessWriter.php - Creates a .htaccess file in the given directory.
- system_check_directory in core/
modules/ system/ system.module - Checks the existence of the directory specified in $form_element.
File
-
core/
lib/ Drupal/ Component/ FileSecurity/ FileSecurity.php, line 28
Class
- FileSecurity
- Provides file security functions.
Namespace
Drupal\Component\FileSecurityCode
public static function writeHtaccess($directory, $deny_public_access = TRUE, $force = FALSE) {
return self::writeFile($directory, '.htaccess', self::htaccessLines($deny_public_access), $force);
}