protected function Local::writeHtaccess in Flysystem 7
Same name and namespace in other branches
- 8 src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::writeHtaccess()
- 3.x src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::writeHtaccess()
- 2.0.x src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::writeHtaccess()
- 3.0.x src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::writeHtaccess()
Writes an .htaccess file.
Parameters
string $directory: The directory to write the .htaccess file.
bool $force: Whether to overwrite an existing file.
Return value
bool True on success, false on failure.
2 calls to Local::writeHtaccess()
- Local::ensure in src/
Flysystem/ Local.php - Local::__construct in src/
Flysystem/ Local.php - Constructs a Local object.
File
- src/
Flysystem/ Local.php, line 197 - Contains \Drupal\flysystem\Flysystem\Local.
Class
- Local
- Drupal plugin for the "Local" Flysystem adapter.
Namespace
Drupal\flysystem\FlysystemCode
protected function writeHtaccess($directory, $force = FALSE) {
$htaccess_path = $directory . '/.htaccess';
if (file_exists($htaccess_path) && !$force) {
// Short circuit if the .htaccess file already exists.
return TRUE;
}
// Write the .htaccess file.
if (is_dir($directory) && is_writable($directory)) {
return file_put_contents($htaccess_path, file_htaccess_lines()) && chmod($htaccess_path, 0444);
}
return FALSE;
}