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

Breadcrumb

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

function HtaccessWriter::ensure

Overrides HtaccessWriterInterface::ensure

File

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

Class

HtaccessWriter
Provides functions to manage Apache .htaccess files.

Namespace

Drupal\Core\File

Code

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());
    }
}

API Navigation

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