class HtaccessWriter implements HtaccessWriterInterface (View source)

Provides functions to manage Apache .htaccess files.

Properties

protected StreamWrapperManagerInterface $streamWrapperManager

The stream wrapper manager.

protected LoggerInterface $logger

The logger.

Methods

__construct(LoggerInterface $logger, StreamWrapperManagerInterface $stream_wrapper_manager)

Htaccess constructor.

ensure()

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

bool
write(string $directory, bool $deny_public_access = TRUE, bool $force_overwrite = FALSE)

Creates a .htaccess file in the given directory.

defaultProtectedDirs()

Returns a list of the default protected directories.

Details

__construct(LoggerInterface $logger, StreamWrapperManagerInterface $stream_wrapper_manager)

Htaccess constructor.

Parameters

LoggerInterface $logger

The logger.

StreamWrapperManagerInterface $stream_wrapper_manager

The stream wrapper manager.

ensure()

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

bool write(string $directory, bool $deny_public_access = TRUE, bool $force_overwrite = FALSE)

internal  
 

Creates a .htaccess file in the given directory.

Parameters

string $directory

The directory.

bool $deny_public_access

(Optional) FALSE indicates that $directory should be a web-accessible directory. Defaults to TRUE which indicates a private directory.

bool $force_overwrite

(Optional) Set to TRUE to attempt to overwrite the existing .htaccess file if one is already present. Defaults to FALSE.

Return Value

bool

TRUE if the .htaccess file was saved or already exists, FALSE otherwise.

See also

FileSecurity::writeHtaccess

ProtectedDirectory[] defaultProtectedDirs()

Returns a list of the default protected directories.

Return Value

ProtectedDirectory[]

The default protected directories.