You are here

function file_ensure_htaccess in Drupal 8

Same name and namespace in other branches
  1. 7 includes/file.inc \file_ensure_htaccess()

Creates a .htaccess file in each Drupal files directory if it is missing.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\File\HtaccessWriterInterface::ensure() instead.

See also

https://www.drupal.org/node/2940126

Related topics

2 calls to file_ensure_htaccess()
file_unmanaged_prepare in core/includes/file.inc
Internal function that prepares the destination for a file_unmanaged_copy or file_unmanaged_move operation.
HtaccessDeprecationTest::testDeprecatedFunctions in core/tests/Drupal/KernelTests/Core/File/HtaccessDeprecationTest.php
Tests messages for deprecated functions.

File

core/includes/file.inc, line 333
API for handling file uploads and server file management.

Code

function file_ensure_htaccess() {
  @trigger_error("file_ensure_htaccess() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \\Drupal\\Core\\File\\HtaccessWriter::ensure() instead. See https://www.drupal.org/node/2940126", E_USER_DEPRECATED);
  \Drupal::service('file.htaccess_writer')
    ->ensure();
}