public function HtaccessWriter::ensure in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/File/HtaccessWriter.php \Drupal\Core\File\HtaccessWriter::ensure()
- 9 core/lib/Drupal/Core/File/HtaccessWriter.php \Drupal\Core\File\HtaccessWriter::ensure()
File
- core/
lib/ Drupal/ Core/ File/ HtaccessWriter.php, line 47
Class
- HtaccessWriter
- Provides functions to manage Apache .htaccess files.
Namespace
Drupal\Core\FileCode
public function ensure() {
try {
foreach ($this
->defaultProtectedDirs() as $protected_dir) {
$this
->write($protected_dir
->getPath(), $protected_dir
->isPrivate());
}
$staging = Settings::get('config_sync_directory', FALSE);
if ($staging) {
// Note that we log an error here if we can't write the .htaccess file.
// This can occur if the staging directory is read-only. If it is then
// it is the user's responsibility to create the .htaccess file.
$this
->write($staging, TRUE);
}
} catch (\Exception $e) {
$this->logger
->error($e
->getMessage());
}
}