You are here

private function BackupDatabaseFileHandler::createFilePath in Backup Database 8

Create export location.

1 call to BackupDatabaseFileHandler::createFilePath()
BackupDatabaseFileHandler::setupFile in src/BackupDatabaseFileHandler.php
Handles file generation.

File

src/BackupDatabaseFileHandler.php, line 103
Contains \Drupal\backup_db\BackupDatabaseFileHandler

Class

BackupDatabaseFileHandler
BackupDatabaseFileHandler class.

Namespace

Drupal\backup_db

Code

private function createFilePath() {
  $result = $this->config['path'];
  if (!file_prepare_directory($result, FILE_CREATE_DIRECTORY)) {
    $result = FALSE;
    \Drupal::logger('backup_db')
      ->error('The requested directory @dir could not be created.', array(
      '@dir' => $this->config['path'],
    ));
  }
  else {
    if (!file_prepare_directory($result)) {
      $result = FALSE;
      \Drupal::logger('backup_db')
        ->error('The requested directory @dir permissions are not writable.', array(
        '@dir' => $this->config['path'],
      ));
    }
  }
  if ($this->config['date']) {
    $filepath = $this->config['path'] . '/' . $this->config['date'];
    if (file_prepare_directory($filepath, FILE_CREATE_DIRECTORY)) {
      $result = $filepath;
    }
  }
  return $result;
}