You are here

protected function DevelMailLog::prepareDirectory in Devel 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::prepareDirectory()
  2. 8.2 src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::prepareDirectory()
  3. 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

$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 177

Class

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

Namespace

Drupal\devel\Plugin\Mail

Code

protected function prepareDirectory($directory) {
  if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) {
    return FALSE;
  }
  if (0 === strpos($directory, 'public://')) {
    return file_save_htaccess($directory);
  }
  return TRUE;
}