Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HtaccessWriter.php

function 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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal