function HtaccessWriter::defaultProtectedDirs

Same name in other branches
  1. 9 core/lib/Drupal/Core/File/HtaccessWriter.php \Drupal\Core\File\HtaccessWriter::defaultProtectedDirs()
  2. 8.9.x core/lib/Drupal/Core/File/HtaccessWriter.php \Drupal\Core\File\HtaccessWriter::defaultProtectedDirs()
  3. 10 core/lib/Drupal/Core/File/HtaccessWriter.php \Drupal\Core\File\HtaccessWriter::defaultProtectedDirs()

Overrides HtaccessWriterInterface::defaultProtectedDirs

1 call to HtaccessWriter::defaultProtectedDirs()
HtaccessWriter::ensure in core/lib/Drupal/Core/File/HtaccessWriter.php
Creates a .htaccess file in each Drupal files directory if it is missing.

File

core/lib/Drupal/Core/File/HtaccessWriter.php, line 104

Class

HtaccessWriter
Provides functions to manage Apache .htaccess files.

Namespace

Drupal\Core\File

Code

public function defaultProtectedDirs() {
    $protected_dirs[] = new ProtectedDirectory('Public files directory', 'public://');
    if (PrivateStream::basePath()) {
        $protected_dirs[] = new ProtectedDirectory('Private files directory', 'private://', TRUE);
    }
    $protected_dirs[] = new ProtectedDirectory('Temporary files directory', 'temporary://');
    // The assets path may be the same as the public file path, if so don't try
    // to write the same .htaccess twice.
    $public_path = Settings::get('file_public_path', 'sites/default/files');
    $assets_path = Settings::get('file_assets_path', $public_path);
    if ($assets_path !== $public_path) {
        $protected_dirs[] = new ProtectedDirectory('Optimized assets directory', $assets_path);
    }
    return $protected_dirs;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.