function DevelMailLog::prepareDirectory

Same name in other branches
  1. 4.x src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::prepareDirectory()

Checks that the directory exists and is writable.

Public directories will be protected by adding an .htaccess which indicates that the directory is private.

Parameters

string $directory: A string reference containing the name of a directory path or URI.

Return value

bool TRUE if the directory exists (or was created), is writable and is protected (if it is public). FALSE otherwise.

1 call to DevelMailLog::prepareDirectory()
DevelMailLog::mail in src/Plugin/Mail/DevelMailLog.php
Sends a message composed by \Drupal\Core\Mail\MailManagerInterface->mail().

File

src/Plugin/Mail/DevelMailLog.php, line 171

Class

DevelMailLog
Defines a mail backend that saves emails as temporary files.

Namespace

Drupal\devel\Plugin\Mail

Code

protected function prepareDirectory(string $directory) : bool {
    if (!$this->fileSystem
        ->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY)) {
        return FALSE;
    }
    if (str_starts_with($directory, 'public://')) {
        return FileSecurity::writeHtaccess($directory);
    }
    return TRUE;
}