function HtaccessWriter::ensure

Same name in other branches
  1. 9 core/lib/Drupal/Core/File/HtaccessWriter.php \Drupal\Core\File\HtaccessWriter::ensure()
  2. 10 core/lib/Drupal/Core/File/HtaccessWriter.php \Drupal\Core\File\HtaccessWriter::ensure()
  3. 11.x core/lib/Drupal/Core/File/HtaccessWriter.php \Drupal\Core\File\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());
    }
}

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